38 Err => True |
38 Err => True |
39 | Ok t => (case a' of Err => False | Ok t' => P t' t)" |
39 | Ok t => (case a' of Err => False | Ok t' => P t' t)" |
40 |
40 |
41 (* lifts a relation to option with None as bottom element *) |
41 (* lifts a relation to option with None as bottom element *) |
42 lift_bottom :: "('a => 'b => bool) => ('a option => 'b option => bool)" |
42 lift_bottom :: "('a => 'b => bool) => ('a option => 'b option => bool)" |
43 "lift_bottom P a' a == case a' of |
43 "lift_bottom P a' a == |
44 None => True |
44 case a' of |
45 | Some t' => (case a of None => False | Some t => P t' t)" |
45 None => True |
46 |
46 | Some t' => (case a of None => False | Some t => P t' t)" |
47 sup_ty_opt :: "['code prog,ty err,ty err] => bool" ("_ \<turnstile> _ <=o _" [71,71] 70) |
47 |
|
48 sup_ty_opt :: "['code prog,ty err,ty err] => bool" |
|
49 ("_ \<turnstile> _ <=o _" [71,71] 70) |
48 "sup_ty_opt G == lift_top (\<lambda>t t'. G \<turnstile> t \<preceq> t')" |
50 "sup_ty_opt G == lift_top (\<lambda>t t'. G \<turnstile> t \<preceq> t')" |
49 |
51 |
50 sup_loc :: "['code prog,locvars_type,locvars_type] => bool" |
52 sup_loc :: "['code prog,locvars_type,locvars_type] => bool" |
51 ("_ \<turnstile> _ <=l _" [71,71] 70) |
53 ("_ \<turnstile> _ <=l _" [71,71] 70) |
52 "G \<turnstile> LT <=l LT' == list_all2 (\<lambda>t t'. (G \<turnstile> t <=o t')) LT LT'" |
54 "G \<turnstile> LT <=l LT' == list_all2 (\<lambda>t t'. (G \<turnstile> t <=o t')) LT LT'" |
53 |
55 |
54 sup_state :: "['code prog,state_type,state_type] => bool" |
56 sup_state :: "['code prog,state_type,state_type] => bool" |
55 ("_ \<turnstile> _ <=s _" [71,71] 70) |
57 ("_ \<turnstile> _ <=s _" [71,71] 70) |
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'" |
58 "G \<turnstile> s <=s s' == |
|
59 (G \<turnstile> map Ok (fst s) <=l map Ok (fst s')) \<and> G \<turnstile> snd s <=l snd s'" |
57 |
60 |
58 sup_state_opt :: "['code prog,state_type option,state_type option] => bool" |
61 sup_state_opt :: "['code prog,state_type option,state_type option] => bool" |
59 ("_ \<turnstile> _ <=' _" [71,71] 70) |
62 ("_ \<turnstile> _ <=' _" [71,71] 70) |
60 "sup_state_opt G == lift_bottom (\<lambda>t t'. G \<turnstile> t <=s t')" |
63 "sup_state_opt G == lift_bottom (\<lambda>t t'. G \<turnstile> t <=s t')" |
61 |
64 |
62 syntax (HTML output) |
65 syntax (HTML output) |
63 sup_ty_opt :: "['code prog,ty err,ty err] => bool" ("_ |- _ <=o _") |
66 sup_ty_opt :: "['code prog,ty err,ty err] => bool" |
64 sup_loc :: "['code prog,locvars_type,locvars_type] => bool" ("_ |- _ <=l _" [71,71] 70) |
67 ("_ |- _ <=o _") |
65 sup_state :: "['code prog,state_type,state_type] => bool" ("_ |- _ <=s _" [71,71] 70) |
68 sup_loc :: "['code prog,locvars_type,locvars_type] => bool" |
66 sup_state_opt :: "['code prog,state_type option,state_type option] => bool" ("_ |- _ <=' _" [71,71] 70) |
69 ("_ |- _ <=l _" [71,71] 70) |
|
70 sup_state :: "['code prog,state_type,state_type] => bool" |
|
71 ("_ |- _ <=s _" [71,71] 70) |
|
72 sup_state_opt :: "['code prog,state_type option,state_type option] => bool" |
|
73 ("_ |- _ <=' _" [71,71] 70) |
67 |
74 |
68 |
75 |
69 lemma not_Err_eq [iff]: |
76 lemma not_Err_eq [iff]: |
70 "(x \<noteq> Err) = (\<exists>a. x = Ok a)" |
77 "(x \<noteq> Err) = (\<exists>a. x = Ok a)" |
71 by (cases x) auto |
78 by (cases x) auto |
78 lemma lift_top_refl [simp]: |
85 lemma lift_top_refl [simp]: |
79 "[| !!x. P x x |] ==> lift_top P x x" |
86 "[| !!x. P x x |] ==> lift_top P x x" |
80 by (simp add: lift_top_def split: err.splits) |
87 by (simp add: lift_top_def split: err.splits) |
81 |
88 |
82 lemma lift_top_trans [trans]: |
89 lemma lift_top_trans [trans]: |
83 "[| !!x y z. [| P x y; P y z |] ==> P x z; lift_top P x y; lift_top P y z |] |
90 "[| !!x y z. [| P x y; P y z |] ==> P x z; lift_top P x y; lift_top P y z |] |
84 ==> lift_top P x z" |
91 ==> lift_top P x z" |
85 proof - |
92 proof - |
86 assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z" |
93 assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z" |
87 assume a: "lift_top P x y" |
94 assume a: "lift_top P x y" |
88 assume b: "lift_top P y z" |
95 assume b: "lift_top P y z" |
139 lemma lift_bottom_refl [simp]: |
146 lemma lift_bottom_refl [simp]: |
140 "[| !!x. P x x |] ==> lift_bottom P x x" |
147 "[| !!x. P x x |] ==> lift_bottom P x x" |
141 by (simp add: lift_bottom_def split: option.splits) |
148 by (simp add: lift_bottom_def split: option.splits) |
142 |
149 |
143 lemma lift_bottom_trans [trans]: |
150 lemma lift_bottom_trans [trans]: |
144 "[| !!x y z. [| P x y; P y z |] ==> P x z; lift_bottom P x y; lift_bottom P y z |] |
151 "[| !!x y z. [| P x y; P y z |] ==> P x z; |
|
152 lift_bottom P x y; lift_bottom P y z |] |
145 ==> lift_bottom P x z" |
153 ==> lift_bottom P x z" |
146 proof - |
154 proof - |
147 assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z" |
155 assume [trans]: "!!x y z. [| P x y; P y z |] ==> P x z" |
148 assume a: "lift_bottom P x y" |
156 assume a: "lift_bottom P x y" |
149 assume b: "lift_bottom P y z" |
157 assume b: "lift_bottom P y z" |