author | kleing |
Thu, 21 Sep 2000 10:42:49 +0200 | |
changeset 10042 | 7164dc0d24d8 |
parent 9941 | fe05af7ec816 |
child 10056 | 9f84ffa4a8d0 |
permissions | -rw-r--r-- |
8011 | 1 |
(* Title: HOL/MicroJava/BV/Convert.thy |
2 |
ID: $Id$ |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
3 |
Author: Cornelia Pusch and Gerwin Klein |
8011 | 4 |
Copyright 1999 Technische Universitaet Muenchen |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
5 |
*) |
8011 | 6 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
7 |
header "Lifted Type Relations" |
8011 | 8 |
|
9594 | 9 |
theory Convert = JVMExec: |
8011 | 10 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
11 |
text "The supertype relation lifted to type err, type lists and state types." |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
12 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
13 |
datatype 'a err = Err | Ok 'a |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
14 |
|
8011 | 15 |
types |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
16 |
locvars_type = "ty err list" |
9594 | 17 |
opstack_type = "ty list" |
18 |
state_type = "opstack_type \<times> locvars_type" |
|
8011 | 19 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
20 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
21 |
consts |
10042 | 22 |
strict :: "('a => 'b err) => ('a err => 'b err)" |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
23 |
primrec |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
24 |
"strict f Err = Err" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
25 |
"strict f (Ok x) = f x" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
26 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
27 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
28 |
consts |
10042 | 29 |
val :: "'a err => 'a" |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
30 |
primrec |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
31 |
"val (Ok s) = s" |
8011 | 32 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
33 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
34 |
constdefs |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
35 |
(* lifts a relation to err with Err as top element *) |
10042 | 36 |
lift_top :: "('a => 'b => bool) => ('a err => 'b err => bool)" |
37 |
"lift_top P a' a == case a of |
|
38 |
Err => True |
|
39 |
| Ok t => (case a' of Err => False | Ok t' => P t' t)" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
40 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
41 |
(* lifts a relation to option with None as bottom element *) |
10042 | 42 |
lift_bottom :: "('a => 'b => bool) => ('a option => 'b option => bool)" |
43 |
"lift_bottom P a' a == case a' of |
|
44 |
None => True |
|
45 |
| Some t' => (case a of None => False | Some t => P t' t)" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
46 |
|
10042 | 47 |
sup_ty_opt :: "['code prog,ty err,ty err] => bool" ("_ \<turnstile> _ <=o _" [71,71] 70) |
48 |
"sup_ty_opt G == lift_top (\<lambda>t t'. G \<turnstile> t \<preceq> t')" |
|
49 |
||
50 |
sup_loc :: "['code prog,locvars_type,locvars_type] => bool" |
|
51 |
("_ \<turnstile> _ <=l _" [71,71] 70) |
|
52 |
"G \<turnstile> LT <=l LT' == list_all2 (\<lambda>t t'. (G \<turnstile> t <=o t')) LT LT'" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
53 |
|
10042 | 54 |
sup_state :: "['code prog,state_type,state_type] => bool" |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
55 |
("_ \<turnstile> _ <=s _" [71,71] 70) |
10042 | 56 |
"G \<turnstile> s <=s s' == (G \<turnstile> map Ok (fst s) <=l map Ok (fst s')) \<and> G \<turnstile> snd s <=l snd s'" |
57 |
||
58 |
sup_state_opt :: "['code prog,state_type option,state_type option] => bool" |
|
59 |
("_ \<turnstile> _ <=' _" [71,71] 70) |
|
60 |
"sup_state_opt G == lift_bottom (\<lambda>t t'. G \<turnstile> t <=s t')" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
61 |
|
10042 | 62 |
syntax (HTML output) |
63 |
sup_ty_opt :: "['code prog,ty err,ty err] => bool" ("_ |- _ <=o _") |
|
64 |
sup_loc :: "['code prog,locvars_type,locvars_type] => bool" ("_ |- _ <=l _" [71,71] 70) |
|
65 |
sup_state :: "['code prog,state_type,state_type] => bool" ("_ |- _ <=s _" [71,71] 70) |
|
66 |
sup_state_opt :: "['code prog,state_type option,state_type option] => bool" ("_ |- _ <=' _" [71,71] 70) |
|
67 |
||
9594 | 68 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
69 |
lemma not_Err_eq [iff]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
70 |
"(x \<noteq> Err) = (\<exists>a. x = Ok a)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
71 |
by (cases x) auto |
9594 | 72 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
73 |
lemma not_Some_eq [iff]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
74 |
"(\<forall>y. x \<noteq> Ok y) = (x = Err)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
75 |
by (cases x) auto |
9594 | 76 |
|
77 |
||
78 |
lemma lift_top_refl [simp]: |
|
79 |
"[| !!x. P x x |] ==> lift_top P x x" |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
80 |
by (simp add: lift_top_def split: err.splits) |
9594 | 81 |
|
82 |
lemma lift_top_trans [trans]: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
83 |
"[| !!x y z. [| P x y; P y z |] ==> P x z; lift_top P x y; lift_top P y z |] |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
84 |
==> lift_top P x z" |
9594 | 85 |
proof - |
86 |
assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z" |
|
87 |
assume a: "lift_top P x y" |
|
88 |
assume b: "lift_top P y z" |
|
89 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
90 |
{ assume "z = Err" |
9594 | 91 |
hence ?thesis by (simp add: lift_top_def) |
92 |
} note z_none = this |
|
93 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
94 |
{ assume "x = Err" |
9594 | 95 |
with a b |
96 |
have ?thesis |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
97 |
by (simp add: lift_top_def split: err.splits) |
9594 | 98 |
} note x_none = this |
99 |
||
100 |
{ fix r t |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
101 |
assume x: "x = Ok r" and z: "z = Ok t" |
9594 | 102 |
with a b |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
103 |
obtain s where y: "y = Ok s" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
104 |
by (simp add: lift_top_def split: err.splits) |
9594 | 105 |
|
106 |
from a x y |
|
107 |
have "P r s" by (simp add: lift_top_def) |
|
108 |
also |
|
109 |
from b y z |
|
110 |
have "P s t" by (simp add: lift_top_def) |
|
111 |
finally |
|
112 |
have "P r t" . |
|
113 |
||
114 |
with x z |
|
115 |
have ?thesis by (simp add: lift_top_def) |
|
116 |
} |
|
117 |
||
118 |
with x_none z_none |
|
119 |
show ?thesis by blast |
|
120 |
qed |
|
121 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
122 |
lemma lift_top_Err_any [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
123 |
"lift_top P Err any = (any = Err)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
124 |
by (simp add: lift_top_def split: err.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
125 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
126 |
lemma lift_top_Ok_Ok [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
127 |
"lift_top P (Ok a) (Ok b) = P a b" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
128 |
by (simp add: lift_top_def split: err.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
129 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
130 |
lemma lift_top_any_Ok [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
131 |
"lift_top P any (Ok b) = (\<exists>a. any = Ok a \<and> P a b)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
132 |
by (simp add: lift_top_def split: err.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
133 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
134 |
lemma lift_top_Ok_any: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
135 |
"lift_top P (Ok a) any = (any = Err \<or> (\<exists>b. any = Ok b \<and> P a b))" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
136 |
by (simp add: lift_top_def split: err.splits) |
9594 | 137 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
138 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
139 |
lemma lift_bottom_refl [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
140 |
"[| !!x. P x x |] ==> lift_bottom P x x" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
141 |
by (simp add: lift_bottom_def split: option.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
142 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
143 |
lemma lift_bottom_trans [trans]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
144 |
"[| !!x y z. [| P x y; P y z |] ==> P x z; lift_bottom P x y; lift_bottom P y z |] |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
145 |
==> lift_bottom P x z" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
146 |
proof - |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
147 |
assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
148 |
assume a: "lift_bottom P x y" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
149 |
assume b: "lift_bottom P y z" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
150 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
151 |
{ assume "x = None" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
152 |
hence ?thesis by (simp add: lift_bottom_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
153 |
} note z_none = this |
9594 | 154 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
155 |
{ assume "z = None" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
156 |
with a b |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
157 |
have ?thesis |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
158 |
by (simp add: lift_bottom_def split: option.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
159 |
} note x_none = this |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
160 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
161 |
{ fix r t |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
162 |
assume x: "x = Some r" and z: "z = Some t" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
163 |
with a b |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
164 |
obtain s where y: "y = Some s" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
165 |
by (simp add: lift_bottom_def split: option.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
166 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
167 |
from a x y |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
168 |
have "P r s" by (simp add: lift_bottom_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
169 |
also |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
170 |
from b y z |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
171 |
have "P s t" by (simp add: lift_bottom_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
172 |
finally |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
173 |
have "P r t" . |
9594 | 174 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
175 |
with x z |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
176 |
have ?thesis by (simp add: lift_bottom_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
177 |
} |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
178 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
179 |
with x_none z_none |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
180 |
show ?thesis by blast |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
181 |
qed |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
182 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
183 |
lemma lift_bottom_any_None [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
184 |
"lift_bottom P any None = (any = None)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
185 |
by (simp add: lift_bottom_def split: option.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
186 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
187 |
lemma lift_bottom_Some_Some [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
188 |
"lift_bottom P (Some a) (Some b) = P a b" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
189 |
by (simp add: lift_bottom_def split: option.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
190 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
191 |
lemma lift_bottom_any_Some [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
192 |
"lift_bottom P (Some a) any = (\<exists>b. any = Some b \<and> P a b)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
193 |
by (simp add: lift_bottom_def split: option.splits) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
194 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
195 |
lemma lift_bottom_Some_any: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
196 |
"lift_bottom P any (Some b) = (any = None \<or> (\<exists>a. any = Some a \<and> P a b))" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
197 |
by (simp add: lift_bottom_def split: option.splits) |
9594 | 198 |
|
199 |
||
200 |
||
201 |
theorem sup_ty_opt_refl [simp]: |
|
202 |
"G \<turnstile> t <=o t" |
|
203 |
by (simp add: sup_ty_opt_def) |
|
204 |
||
205 |
theorem sup_loc_refl [simp]: |
|
206 |
"G \<turnstile> t <=l t" |
|
207 |
by (induct t, auto simp add: sup_loc_def) |
|
208 |
||
209 |
theorem sup_state_refl [simp]: |
|
210 |
"G \<turnstile> s <=s s" |
|
211 |
by (simp add: sup_state_def) |
|
212 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
213 |
theorem sup_state_opt_refl [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
214 |
"G \<turnstile> s <=' s" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
215 |
by (simp add: sup_state_opt_def) |
9594 | 216 |
|
217 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
218 |
theorem anyConvErr [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
219 |
"(G \<turnstile> Err <=o any) = (any = Err)" |
9594 | 220 |
by (simp add: sup_ty_opt_def) |
221 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
222 |
theorem OkanyConvOk [simp]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
223 |
"(G \<turnstile> (Ok ty') <=o (Ok ty)) = (G \<turnstile> ty' \<preceq> ty)" |
9594 | 224 |
by (simp add: sup_ty_opt_def) |
225 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
226 |
theorem sup_ty_opt_Ok: |
10042 | 227 |
"G \<turnstile> a <=o (Ok b) ==> \<exists> x. a = Ok x" |
9594 | 228 |
by (clarsimp simp add: sup_ty_opt_def) |
229 |
||
230 |
lemma widen_PrimT_conv1 [simp]: |
|
231 |
"[| G \<turnstile> S \<preceq> T; S = PrimT x|] ==> T = PrimT x" |
|
232 |
by (auto elim: widen.elims) |
|
233 |
||
234 |
theorem sup_PTS_eq: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
235 |
"(G \<turnstile> Ok (PrimT p) <=o X) = (X=Err \<or> X = Ok (PrimT p))" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
236 |
by (auto simp add: sup_ty_opt_def lift_top_Ok_any) |
9594 | 237 |
|
238 |
||
239 |
||
240 |
theorem sup_loc_Nil [iff]: |
|
241 |
"(G \<turnstile> [] <=l XT) = (XT=[])" |
|
242 |
by (simp add: sup_loc_def) |
|
243 |
||
244 |
theorem sup_loc_Cons [iff]: |
|
245 |
"(G \<turnstile> (Y#YT) <=l XT) = (\<exists>X XT'. XT=X#XT' \<and> (G \<turnstile> Y <=o X) \<and> (G \<turnstile> YT <=l XT'))" |
|
246 |
by (simp add: sup_loc_def list_all2_Cons1) |
|
247 |
||
248 |
theorem sup_loc_Cons2: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
249 |
"(G \<turnstile> YT <=l (X#XT)) = (\<exists>Y YT'. YT=Y#YT' \<and> (G \<turnstile> Y <=o X) \<and> (G \<turnstile> YT' <=l XT))" |
9594 | 250 |
by (simp add: sup_loc_def list_all2_Cons2) |
251 |
||
252 |
||
253 |
theorem sup_loc_length: |
|
10042 | 254 |
"G \<turnstile> a <=l b ==> length a = length b" |
9594 | 255 |
proof - |
256 |
assume G: "G \<turnstile> a <=l b" |
|
10042 | 257 |
have "\<forall> b. (G \<turnstile> a <=l b) --> length a = length b" |
9594 | 258 |
by (induct a, auto) |
259 |
with G |
|
260 |
show ?thesis by blast |
|
261 |
qed |
|
262 |
||
263 |
theorem sup_loc_nth: |
|
264 |
"[| G \<turnstile> a <=l b; n < length a |] ==> G \<turnstile> (a!n) <=o (b!n)" |
|
265 |
proof - |
|
266 |
assume a: "G \<turnstile> a <=l b" "n < length a" |
|
10042 | 267 |
have "\<forall> n b. (G \<turnstile> a <=l b) --> n < length a --> (G \<turnstile> (a!n) <=o (b!n))" |
9594 | 268 |
(is "?P a") |
269 |
proof (induct a) |
|
270 |
show "?P []" by simp |
|
271 |
||
272 |
fix x xs assume IH: "?P xs" |
|
273 |
||
274 |
show "?P (x#xs)" |
|
275 |
proof (intro strip) |
|
276 |
fix n b |
|
277 |
assume "G \<turnstile> (x # xs) <=l b" "n < length (x # xs)" |
|
278 |
with IH |
|
279 |
show "G \<turnstile> ((x # xs) ! n) <=o (b ! n)" |
|
280 |
by - (cases n, auto) |
|
281 |
qed |
|
282 |
qed |
|
283 |
with a |
|
284 |
show ?thesis by blast |
|
285 |
qed |
|
286 |
||
287 |
||
288 |
theorem all_nth_sup_loc: |
|
10042 | 289 |
"\<forall>b. length a = length b --> (\<forall> n. n < length a --> (G \<turnstile> (a!n) <=o (b!n))) --> |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
290 |
(G \<turnstile> a <=l b)" (is "?P a") |
9594 | 291 |
proof (induct a) |
292 |
show "?P []" by simp |
|
8011 | 293 |
|
9594 | 294 |
fix l ls assume IH: "?P ls" |
295 |
||
296 |
show "?P (l#ls)" |
|
297 |
proof (intro strip) |
|
298 |
fix b |
|
10042 | 299 |
assume f: "\<forall>n. n < length (l # ls) --> (G \<turnstile> ((l # ls) ! n) <=o (b ! n))" |
9594 | 300 |
assume l: "length (l#ls) = length b" |
301 |
||
302 |
then obtain b' bs where b: "b = b'#bs" |
|
303 |
by - (cases b, simp, simp add: neq_Nil_conv, rule that) |
|
304 |
||
305 |
with f |
|
10042 | 306 |
have "\<forall>n. n < length ls --> (G \<turnstile> (ls!n) <=o (bs!n))" |
9594 | 307 |
by auto |
308 |
||
309 |
with f b l IH |
|
310 |
show "G \<turnstile> (l # ls) <=l b" |
|
311 |
by auto |
|
312 |
qed |
|
313 |
qed |
|
314 |
||
315 |
||
316 |
theorem sup_loc_append: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
317 |
"length a = length b ==> |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
318 |
(G \<turnstile> (a@x) <=l (b@y)) = ((G \<turnstile> a <=l b) \<and> (G \<turnstile> x <=l y))" |
9594 | 319 |
proof - |
320 |
assume l: "length a = length b" |
|
321 |
||
10042 | 322 |
have "\<forall>b. length a = length b --> (G \<turnstile> (a@x) <=l (b@y)) = ((G \<turnstile> a <=l b) \<and> |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
323 |
(G \<turnstile> x <=l y))" (is "?P a") |
9594 | 324 |
proof (induct a) |
325 |
show "?P []" by simp |
|
326 |
||
327 |
fix l ls assume IH: "?P ls" |
|
328 |
show "?P (l#ls)" |
|
329 |
proof (intro strip) |
|
330 |
fix b |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
331 |
assume "length (l#ls) = length (b::ty err list)" |
9594 | 332 |
with IH |
333 |
show "(G \<turnstile> ((l#ls)@x) <=l (b@y)) = ((G \<turnstile> (l#ls) <=l b) \<and> (G \<turnstile> x <=l y))" |
|
334 |
by - (cases b, auto) |
|
335 |
qed |
|
336 |
qed |
|
337 |
with l |
|
338 |
show ?thesis by blast |
|
339 |
qed |
|
340 |
||
341 |
theorem sup_loc_rev [simp]: |
|
342 |
"(G \<turnstile> (rev a) <=l rev b) = (G \<turnstile> a <=l b)" |
|
343 |
proof - |
|
344 |
have "\<forall>b. (G \<turnstile> (rev a) <=l rev b) = (G \<turnstile> a <=l b)" (is "\<forall>b. ?Q a b" is "?P a") |
|
345 |
proof (induct a) |
|
346 |
show "?P []" by simp |
|
347 |
||
348 |
fix l ls assume IH: "?P ls" |
|
349 |
||
350 |
{ |
|
351 |
fix b |
|
352 |
have "?Q (l#ls) b" |
|
9664 | 353 |
proof (cases (open) b) |
9594 | 354 |
case Nil |
355 |
thus ?thesis by (auto dest: sup_loc_length) |
|
356 |
next |
|
357 |
case Cons |
|
358 |
show ?thesis |
|
359 |
proof |
|
360 |
assume "G \<turnstile> (l # ls) <=l b" |
|
361 |
thus "G \<turnstile> rev (l # ls) <=l rev b" |
|
362 |
by (clarsimp simp add: Cons IH sup_loc_length sup_loc_append) |
|
363 |
next |
|
364 |
assume "G \<turnstile> rev (l # ls) <=l rev b" |
|
365 |
hence G: "G \<turnstile> (rev ls @ [l]) <=l (rev list @ [a])" |
|
366 |
by (simp add: Cons) |
|
367 |
||
368 |
hence "length (rev ls) = length (rev list)" |
|
369 |
by (auto dest: sup_loc_length) |
|
370 |
||
371 |
from this G |
|
372 |
obtain "G \<turnstile> rev ls <=l rev list" "G \<turnstile> l <=o a" |
|
373 |
by (simp add: sup_loc_append) |
|
374 |
||
375 |
thus "G \<turnstile> (l # ls) <=l b" |
|
376 |
by (simp add: Cons IH) |
|
377 |
qed |
|
378 |
qed |
|
379 |
} |
|
380 |
thus "?P (l#ls)" by blast |
|
381 |
qed |
|
8011 | 382 |
|
9594 | 383 |
thus ?thesis by blast |
384 |
qed |
|
385 |
||
386 |
||
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9906
diff
changeset
|
387 |
theorem sup_loc_update [rule_format]: |
10042 | 388 |
"\<forall> n y. (G \<turnstile> a <=o b) --> n < length y --> (G \<turnstile> x <=l y) --> |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
389 |
(G \<turnstile> x[n := a] <=l y[n := b])" (is "?P x") |
9594 | 390 |
proof (induct x) |
391 |
show "?P []" by simp |
|
392 |
||
393 |
fix l ls assume IH: "?P ls" |
|
394 |
show "?P (l#ls)" |
|
395 |
proof (intro strip) |
|
396 |
fix n y |
|
397 |
assume "G \<turnstile>a <=o b" "G \<turnstile> (l # ls) <=l y" "n < length y" |
|
398 |
with IH |
|
399 |
show "G \<turnstile> (l # ls)[n := a] <=l y[n := b]" |
|
400 |
by - (cases n, auto simp add: sup_loc_Cons2 list_all2_Cons1) |
|
401 |
qed |
|
402 |
qed |
|
403 |
||
404 |
||
405 |
theorem sup_state_length [simp]: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
406 |
"G \<turnstile> s2 <=s s1 ==> |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
407 |
length (fst s2) = length (fst s1) \<and> length (snd s2) = length (snd s1)" |
9594 | 408 |
by (auto dest: sup_loc_length simp add: sup_state_def); |
409 |
||
410 |
theorem sup_state_append_snd: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
411 |
"length a = length b ==> |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
412 |
(G \<turnstile> (i,a@x) <=s (j,b@y)) = ((G \<turnstile> (i,a) <=s (j,b)) \<and> (G \<turnstile> (i,x) <=s (j,y)))" |
9594 | 413 |
by (auto simp add: sup_state_def sup_loc_append) |
414 |
||
415 |
theorem sup_state_append_fst: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
416 |
"length a = length b ==> |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
417 |
(G \<turnstile> (a@x,i) <=s (b@y,j)) = ((G \<turnstile> (a,i) <=s (b,j)) \<and> (G \<turnstile> (x,i) <=s (y,j)))" |
9594 | 418 |
by (auto simp add: sup_state_def sup_loc_append) |
419 |
||
420 |
theorem sup_state_Cons1: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
421 |
"(G \<turnstile> (x#xt, a) <=s (yt, b)) = |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
422 |
(\<exists>y yt'. yt=y#yt' \<and> (G \<turnstile> x \<preceq> y) \<and> (G \<turnstile> (xt,a) <=s (yt',b)))" |
9594 | 423 |
by (auto simp add: sup_state_def map_eq_Cons) |
424 |
||
425 |
theorem sup_state_Cons2: |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
426 |
"(G \<turnstile> (xt, a) <=s (y#yt, b)) = |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
427 |
(\<exists>x xt'. xt=x#xt' \<and> (G \<turnstile> x \<preceq> y) \<and> (G \<turnstile> (xt',a) <=s (yt,b)))" |
9594 | 428 |
by (auto simp add: sup_state_def map_eq_Cons sup_loc_Cons2) |
429 |
||
430 |
theorem sup_state_ignore_fst: |
|
10042 | 431 |
"G \<turnstile> (a, x) <=s (b, y) ==> G \<turnstile> (c, x) <=s (c, y)" |
9594 | 432 |
by (simp add: sup_state_def) |
433 |
||
434 |
theorem sup_state_rev_fst: |
|
435 |
"(G \<turnstile> (rev a, x) <=s (rev b, y)) = (G \<turnstile> (a, x) <=s (b, y))" |
|
436 |
proof - |
|
437 |
have m: "!!f x. map f (rev x) = rev (map f x)" by (simp add: rev_map) |
|
438 |
show ?thesis by (simp add: m sup_state_def) |
|
439 |
qed |
|
440 |
||
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
441 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
442 |
lemma sup_state_opt_None_any [iff]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
443 |
"(G \<turnstile> None <=' any) = True" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
444 |
by (simp add: sup_state_opt_def lift_bottom_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
445 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
446 |
lemma sup_state_opt_any_None [iff]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
447 |
"(G \<turnstile> any <=' None) = (any = None)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
448 |
by (simp add: sup_state_opt_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
449 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
450 |
lemma sup_state_opt_Some_Some [iff]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
451 |
"(G \<turnstile> (Some a) <=' (Some b)) = (G \<turnstile> a <=s b)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
452 |
by (simp add: sup_state_opt_def del: split_paired_Ex) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
453 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
454 |
lemma sup_state_opt_any_Some [iff]: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
455 |
"(G \<turnstile> (Some a) <=' any) = (\<exists>b. any = Some b \<and> G \<turnstile> a <=s b)" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
456 |
by (simp add: sup_state_opt_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
457 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
458 |
lemma sup_state_opt_Some_any: |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
459 |
"(G \<turnstile> any <=' (Some b)) = (any = None \<or> (\<exists>a. any = Some a \<and> G \<turnstile> a <=s b))" |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
460 |
by (simp add: sup_state_opt_def lift_bottom_Some_any) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
461 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
462 |
|
9594 | 463 |
theorem sup_ty_opt_trans [trans]: |
10042 | 464 |
"[|G \<turnstile> a <=o b; G \<turnstile> b <=o c|] ==> G \<turnstile> a <=o c" |
9594 | 465 |
by (auto intro: lift_top_trans widen_trans simp add: sup_ty_opt_def) |
466 |
||
467 |
theorem sup_loc_trans [trans]: |
|
10042 | 468 |
"[|G \<turnstile> a <=l b; G \<turnstile> b <=l c|] ==> G \<turnstile> a <=l c" |
9594 | 469 |
proof - |
470 |
assume G: "G \<turnstile> a <=l b" "G \<turnstile> b <=l c" |
|
471 |
||
10042 | 472 |
hence "\<forall> n. n < length a --> (G \<turnstile> (a!n) <=o (c!n))" |
9594 | 473 |
proof (intro strip) |
474 |
fix n |
|
475 |
assume n: "n < length a" |
|
476 |
with G |
|
477 |
have "G \<turnstile> (a!n) <=o (b!n)" |
|
478 |
by - (rule sup_loc_nth) |
|
479 |
also |
|
480 |
from n G |
|
481 |
have "G \<turnstile> ... <=o (c!n)" |
|
482 |
by - (rule sup_loc_nth, auto dest: sup_loc_length) |
|
483 |
finally |
|
484 |
show "G \<turnstile> (a!n) <=o (c!n)" . |
|
485 |
qed |
|
486 |
||
487 |
with G |
|
488 |
show ?thesis |
|
9941
fe05af7ec816
renamed atts: rulify to rule_format, elimify to elim_format;
wenzelm
parents:
9906
diff
changeset
|
489 |
by (auto intro!: all_nth_sup_loc [rule_format] dest!: sup_loc_length) |
9594 | 490 |
qed |
491 |
||
492 |
||
493 |
theorem sup_state_trans [trans]: |
|
10042 | 494 |
"[|G \<turnstile> a <=s b; G \<turnstile> b <=s c|] ==> G \<turnstile> a <=s c" |
9594 | 495 |
by (auto intro: sup_loc_trans simp add: sup_state_def) |
8011 | 496 |
|
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
497 |
theorem sup_state_opt_trans [trans]: |
10042 | 498 |
"[|G \<turnstile> a <=' b; G \<turnstile> b <=' c|] ==> G \<turnstile> a <=' c" |
9757
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
499 |
by (auto intro: lift_bottom_trans sup_state_trans simp add: sup_state_opt_def) |
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
500 |
|
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
kleing
parents:
9664
diff
changeset
|
501 |
|
8011 | 502 |
end |