author | Christian Urban <urbanc@in.tum.de> |
Tue, 27 Jun 2017 13:15:55 +0100 | |
changeset 254 | 7c89d3f6923e |
parent 248 | b90ff5abb437 |
child 255 | 222ed43892ea |
permissions | -rw-r--r-- |
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
1 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
2 |
theory Sulzmann |
254 | 3 |
imports "Positions" |
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
4 |
begin |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
5 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
6 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
7 |
section {* Sulzmann's "Ordering" of Values *} |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
8 |
|
245 | 9 |
inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<preceq>_ _" [100, 100, 100] 100) |
10 |
where |
|
11 |
C2: "v1 \<preceq>r1 v1' \<Longrightarrow> (Seq v1 v2) \<preceq>(SEQ r1 r2) (Seq v1' v2')" |
|
12 |
| C1: "v2 \<preceq>r2 v2' \<Longrightarrow> (Seq v1 v2) \<preceq>(SEQ r1 r2) (Seq v1 v2')" |
|
13 |
| A1: "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<preceq>(ALT r1 r2) (Left v1)" |
|
14 |
| A2: "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<preceq>(ALT r1 r2) (Right v2)" |
|
15 |
| A3: "v2 \<preceq>r2 v2' \<Longrightarrow> (Right v2) \<preceq>(ALT r1 r2) (Right v2')" |
|
16 |
| A4: "v1 \<preceq>r1 v1' \<Longrightarrow> (Left v1) \<preceq>(ALT r1 r2) (Left v1')" |
|
17 |
| K1: "flat (Stars (v # vs)) = [] \<Longrightarrow> (Stars []) \<preceq>(STAR r) (Stars (v # vs))" |
|
18 |
| K2: "flat (Stars (v # vs)) \<noteq> [] \<Longrightarrow> (Stars (v # vs)) \<preceq>(STAR r) (Stars [])" |
|
19 |
| K3: "v1 \<preceq>r v2 \<Longrightarrow> (Stars (v1 # vs1)) \<preceq>(STAR r) (Stars (v2 # vs2))" |
|
20 |
| K4: "(Stars vs1) \<preceq>(STAR r) (Stars vs2) \<Longrightarrow> (Stars (v # vs1)) \<preceq>(STAR r) (Stars (v # vs2))" |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
21 |
(*| MY1: "Void \<preceq>ONE Void" |
245 | 22 |
| MY2: "(Char c) \<preceq>(CHAR c) (Char c)" |
23 |
| MY3: "(Stars []) \<preceq>(STAR r) (Stars [])" |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
24 |
*) |
245 | 25 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
26 |
(* |
245 | 27 |
lemma ValOrd_refl: |
28 |
assumes "\<turnstile> v : r" |
|
29 |
shows "v \<preceq>r v" |
|
30 |
using assms |
|
31 |
apply(induct r rule: Prf.induct) |
|
32 |
apply(rule ValOrd.intros) |
|
33 |
apply(simp) |
|
34 |
apply(rule ValOrd.intros) |
|
35 |
apply(simp) |
|
36 |
apply(rule ValOrd.intros) |
|
37 |
apply(simp) |
|
38 |
apply(rule ValOrd.intros) |
|
39 |
apply(rule ValOrd.intros) |
|
40 |
apply(rule ValOrd.intros) |
|
41 |
apply(rule ValOrd.intros) |
|
42 |
apply(simp) |
|
43 |
done |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
44 |
*) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
45 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
46 |
lemma ValOrd_irrefl: |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
47 |
assumes "\<turnstile> v : r" "v \<preceq>r v" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
48 |
shows "False" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
49 |
using assms |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
50 |
apply(induct v r rule: Prf.induct) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
51 |
apply(erule ValOrd.cases) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
52 |
apply(simp_all) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
53 |
apply(erule ValOrd.cases) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
54 |
apply(simp_all) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
55 |
apply(erule ValOrd.cases) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
56 |
apply(simp_all) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
57 |
apply(erule ValOrd.cases) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
58 |
apply(simp_all) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
59 |
apply(erule ValOrd.cases) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
60 |
apply(simp_all) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
61 |
apply(erule ValOrd.cases) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
62 |
apply(simp_all) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
63 |
apply(erule ValOrd.cases) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
64 |
apply(simp_all) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
65 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
66 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
67 |
lemma prefix_sprefix: |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
68 |
shows "xs \<sqsubseteq>pre ys \<longleftrightarrow> (xs = ys \<or> xs \<sqsubset>spre ys)" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
69 |
apply(auto simp add: sprefix_list_def prefix_list_def) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
70 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
71 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
72 |
|
245 | 73 |
|
74 |
lemma Posix_CPT2: |
|
254 | 75 |
assumes "v1 \<preceq>r v2" "flat v2 \<sqsubseteq>pre s" "flat v1 \<sqsubseteq>pre s" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
76 |
shows "v1 :\<sqsubset>val v2" |
245 | 77 |
using assms |
254 | 78 |
apply(induct v1 r v2 arbitrary: s rule: ValOrd.induct) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
79 |
prefer 3 |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
80 |
apply(simp) |
254 | 81 |
apply(rule val_ord_shorterI) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
82 |
apply(simp) |
254 | 83 |
apply(subst (asm) (3) prefix_list_def) |
84 |
apply(subst (asm) (3) prefix_list_def) |
|
85 |
apply(clarify) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
86 |
apply(simp) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
87 |
apply(simp add: append_eq_append_conv2) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
88 |
apply(auto)[1] |
254 | 89 |
apply(drule_tac x="flat v1' @ flat v2' @ usa" in meta_spec) |
90 |
apply(simp add: prefix_list_def) |
|
91 |
apply(rule val_ord_SeqI1) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
247
diff
changeset
|
92 |
apply(simp) |
245 | 93 |
apply(simp) |
94 |
||
95 |
||
96 |
lemma Posix_CPT: |
|
97 |
assumes "v1 :\<sqsubset>val v2" "v1 \<in> CPT r s" "v2 \<in> CPT r s" |
|
98 |
shows "v1 \<preceq>r v2" |
|
99 |
using assms |
|
100 |
apply(induct r arbitrary: v1 v2 s rule: rexp.induct) |
|
101 |
apply(simp add: CPT_def) |
|
102 |
apply(clarify) |
|
103 |
apply(erule CPrf.cases) |
|
104 |
apply(simp_all) |
|
105 |
apply(simp add: CPT_def) |
|
106 |
apply(clarify) |
|
107 |
apply(erule CPrf.cases) |
|
108 |
apply(simp_all) |
|
109 |
apply(erule CPrf.cases) |
|
110 |
apply(simp_all) |
|
111 |
apply(rule ValOrd.intros) |
|
112 |
apply(simp add: CPT_def) |
|
113 |
apply(clarify) |
|
114 |
apply(erule CPrf.cases) |
|
115 |
apply(simp_all) |
|
116 |
apply(erule CPrf.cases) |
|
117 |
apply(simp_all) |
|
118 |
apply(rule ValOrd.intros) |
|
119 |
(*SEQ case *) |
|
120 |
apply(simp add: CPT_def) |
|
121 |
apply(clarify) |
|
122 |
apply(erule CPrf.cases) |
|
123 |
apply(simp_all) |
|
124 |
apply(clarify) |
|
125 |
apply(erule CPrf.cases) |
|
126 |
apply(simp_all) |
|
127 |
apply(clarify) |
|
128 |
thm val_ord_SEQ |
|
129 |
apply(drule_tac r="r1a" in val_ord_SEQ) |
|
130 |
apply(simp) |
|
131 |
using Prf_CPrf apply blast |
|
132 |
using Prf_CPrf apply blast |
|
133 |
apply(erule disjE) |
|
134 |
apply(rule C2) |
|
135 |
prefer 2 |
|
136 |
apply(simp) |
|
137 |
apply(rule C1) |
|
138 |
apply blast |
|
139 |
||
140 |
apply(simp add: append_eq_append_conv2) |
|
141 |
apply(clarify) |
|
142 |
apply(auto)[1] |
|
143 |
apply(drule_tac x="v1a" in meta_spec) |
|
144 |
apply(rotate_tac 8) |
|
145 |
apply(drule_tac x="v1b" in meta_spec) |
|
146 |
apply(rotate_tac 8) |
|
147 |
apply(simp) |
|
148 |
||
149 |
(* HERE *) |
|
150 |
apply(subst (asm) (3) val_ord_ex_def) |
|
151 |
apply(clarify) |
|
152 |
apply(subst (asm) val_ord_def) |
|
153 |
apply(clarify) |
|
154 |
apply(rule ValOrd.intros) |
|
155 |
||
156 |
||
157 |
apply(simp add: val_ord_ex_def) |
|
158 |
oops |
|
159 |
||
160 |
||
161 |
lemma ValOrd_trans: |
|
162 |
assumes "x \<preceq>r y" "y \<preceq>r z" |
|
163 |
and "x \<in> CPT r s" "y \<in> CPT r s" "z \<in> CPT r s" |
|
164 |
shows "x \<preceq>r z" |
|
165 |
using assms |
|
166 |
apply(induct x r y arbitrary: s z rule: ValOrd.induct) |
|
167 |
apply(rotate_tac 2) |
|
168 |
apply(erule ValOrd.cases) |
|
169 |
apply(simp_all)[13] |
|
170 |
apply(rule ValOrd.intros) |
|
171 |
apply(drule_tac x="s" in meta_spec) |
|
172 |
apply(drule_tac x="v1'a" in meta_spec) |
|
173 |
apply(drule_tac meta_mp) |
|
174 |
apply(simp) |
|
175 |
apply(drule_tac meta_mp) |
|
176 |
apply(simp add: CPT_def) |
|
177 |
oops |
|
178 |
||
179 |
lemma ValOrd_preorder: |
|
180 |
"preorder_on (CPT r s) {(v1, v2). v1 \<preceq>r v2 \<and> v1 \<in> (CPT r s) \<and> v2 \<in> (CPT r s)}" |
|
181 |
apply(simp add: preorder_on_def) |
|
182 |
apply(rule conjI) |
|
183 |
apply(simp add: refl_on_def) |
|
184 |
apply(auto) |
|
185 |
apply(rule ValOrd_refl) |
|
186 |
apply(simp add: CPT_def) |
|
187 |
apply(rule Prf_CPrf) |
|
188 |
apply(auto)[1] |
|
189 |
apply(simp add: trans_def) |
|
190 |
apply(auto) |
|
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
191 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
192 |
definition ValOrdEq :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<ge>_ _" [100, 100, 100] 100) |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
193 |
where |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
194 |
"v\<^sub>1 \<ge>r v\<^sub>2 \<equiv> v\<^sub>1 = v\<^sub>2 \<or> (v\<^sub>1 >r v\<^sub>2 \<and> flat v\<^sub>1 = flat v\<^sub>2)" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
195 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
196 |
(* |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
197 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
198 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
199 |
inductive ValOrd :: "val \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<succ>_ _" [100, 100, 100] 100) |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
200 |
where |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
201 |
"v2 \<succ>r2 v2' \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1 v2')" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
202 |
| "\<lbrakk>v1 \<succ>r1 v1'; v1 \<noteq> v1'\<rbrakk> \<Longrightarrow> (Seq v1 v2) \<succ>(SEQ r1 r2) (Seq v1' v2')" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
203 |
| "length (flat v1) \<ge> length (flat v2) \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Right v2)" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
204 |
| "length (flat v2) > length (flat v1) \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Left v1)" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
205 |
| "v2 \<succ>r2 v2' \<Longrightarrow> (Right v2) \<succ>(ALT r1 r2) (Right v2')" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
206 |
| "v1 \<succ>r1 v1' \<Longrightarrow> (Left v1) \<succ>(ALT r1 r2) (Left v1')" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
207 |
| "Void \<succ>EMPTY Void" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
208 |
| "(Char c) \<succ>(CHAR c) (Char c)" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
209 |
| "flat (Stars (v # vs)) = [] \<Longrightarrow> (Stars []) \<succ>(STAR r) (Stars (v # vs))" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
210 |
| "flat (Stars (v # vs)) \<noteq> [] \<Longrightarrow> (Stars (v # vs)) \<succ>(STAR r) (Stars [])" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
211 |
| "\<lbrakk>v1 \<succ>r v2; v1 \<noteq> v2\<rbrakk> \<Longrightarrow> (Stars (v1 # vs1)) \<succ>(STAR r) (Stars (v2 # vs2))" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
212 |
| "(Stars vs1) \<succ>(STAR r) (Stars vs2) \<Longrightarrow> (Stars (v # vs1)) \<succ>(STAR r) (Stars (v # vs2))" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
213 |
| "(Stars []) \<succ>(STAR r) (Stars [])" |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
214 |
*) |
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
215 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
216 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
217 |
section {* Bit-Encodings *} |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
218 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
219 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
220 |
fun |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
221 |
code :: "val \<Rightarrow> rexp \<Rightarrow> bool list" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
222 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
223 |
"code Void ONE = []" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
224 |
| "code (Char c) (CHAR d) = []" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
225 |
| "code (Left v) (ALT r1 r2) = False # (code v r1)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
226 |
| "code (Right v) (ALT r1 r2) = True # (code v r2)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
227 |
| "code (Seq v1 v2) (SEQ r1 r2) = (code v1 r1) @ (code v2 r2)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
228 |
| "code (Stars []) (STAR r) = [True]" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
229 |
| "code (Stars (v # vs)) (STAR r) = False # (code v r) @ code (Stars vs) (STAR r)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
230 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
231 |
fun |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
232 |
Stars_add :: "val \<Rightarrow> val \<Rightarrow> val" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
233 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
234 |
"Stars_add v (Stars vs) = Stars (v # vs)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
235 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
236 |
function |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
237 |
decode' :: "bool list \<Rightarrow> rexp \<Rightarrow> (val * bool list)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
238 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
239 |
"decode' ds ZERO = (Void, [])" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
240 |
| "decode' ds ONE = (Void, ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
241 |
| "decode' ds (CHAR d) = (Char d, ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
242 |
| "decode' [] (ALT r1 r2) = (Void, [])" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
243 |
| "decode' (False # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r1 in (Left v, ds'))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
244 |
| "decode' (True # ds) (ALT r1 r2) = (let (v, ds') = decode' ds r2 in (Right v, ds'))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
245 |
| "decode' ds (SEQ r1 r2) = (let (v1, ds') = decode' ds r1 in |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
246 |
let (v2, ds'') = decode' ds' r2 in (Seq v1 v2, ds''))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
247 |
| "decode' [] (STAR r) = (Void, [])" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
248 |
| "decode' (True # ds) (STAR r) = (Stars [], ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
249 |
| "decode' (False # ds) (STAR r) = (let (v, ds') = decode' ds r in |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
250 |
let (vs, ds'') = decode' ds' (STAR r) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
251 |
in (Stars_add v vs, ds''))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
252 |
by pat_completeness auto |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
253 |
|
204
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
254 |
termination |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
255 |
apply(size_change) |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
256 |
oops |
cd9e40280784
added paper about size derivatives
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
185
diff
changeset
|
257 |
|
154
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
258 |
term "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
259 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
260 |
lemma decode'_smaller: |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
261 |
assumes "decode'_dom (ds, r)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
262 |
shows "length (snd (decode' ds r)) \<le> length ds" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
263 |
using assms |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
264 |
apply(induct ds r) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
265 |
apply(auto simp add: decode'.psimps split: prod.split) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
266 |
using dual_order.trans apply blast |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
267 |
by (meson dual_order.trans le_SucI) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
268 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
269 |
termination "decode'" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
270 |
apply(relation "inv_image (measure(%cs. size cs) <*lex*> measure(%s. size s)) (%(ds,r). (r,ds))") |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
271 |
apply(auto dest!: decode'_smaller) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
272 |
by (metis less_Suc_eq_le snd_conv) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
273 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
274 |
fun |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
275 |
decode :: "bool list \<Rightarrow> rexp \<Rightarrow> val option" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
276 |
where |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
277 |
"decode ds r = (let (v, ds') = decode' ds r |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
278 |
in (if ds' = [] then Some v else None))" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
279 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
280 |
lemma decode'_code: |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
281 |
assumes "\<turnstile> v : r" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
282 |
shows "decode' ((code v r) @ ds) r = (v, ds)" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
283 |
using assms |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
284 |
by (induct v r arbitrary: ds) (auto) |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
285 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
286 |
|
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
287 |
lemma decode_code: |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
288 |
assumes "\<turnstile> v : r" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
289 |
shows "decode (code v r) r = Some v" |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
290 |
using assms decode'_code[of _ _ "[]"] |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
291 |
by auto |
2de3cf684ba0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
148
diff
changeset
|
292 |
|
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
293 |
datatype arexp = |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
294 |
AZERO |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
295 |
| AONE "bool list" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
296 |
| ACHAR "bool list" char |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
297 |
| ASEQ "bool list" arexp arexp |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
298 |
| AALT "bool list" arexp arexp |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
299 |
| ASTAR "bool list" arexp |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
300 |
|
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
301 |
fun fuse :: "bool list \<Rightarrow> arexp \<Rightarrow> arexp" where |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
302 |
"fuse bs AZERO = AZERO" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
303 |
| "fuse bs (AONE cs) = AONE (bs @ cs)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
304 |
| "fuse bs (ACHAR cs c) = ACHAR (bs @ cs) c" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
305 |
| "fuse bs (AALT cs r1 r2) = AALT (bs @ cs) r1 r2" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
306 |
| "fuse bs (ASEQ cs r1 r2) = ASEQ (bs @ cs) r1 r2" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
307 |
| "fuse bs (ASTAR cs r) = ASTAR (bs @ cs) r" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
308 |
|
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
309 |
fun internalise :: "rexp \<Rightarrow> arexp" where |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
310 |
"internalise ZERO = AZERO" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
311 |
| "internalise ONE = AONE []" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
312 |
| "internalise (CHAR c) = ACHAR [] c" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
313 |
| "internalise (ALT r1 r2) = AALT [] (fuse [False] (internalise r1)) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
314 |
(fuse [True] (internalise r2))" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
315 |
| "internalise (SEQ r1 r2) = ASEQ [] (internalise r1) (internalise r2)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
316 |
| "internalise (STAR r) = ASTAR [] (internalise r)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
317 |
|
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
318 |
fun retrieve :: "arexp \<Rightarrow> val \<Rightarrow> bool list" where |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
319 |
"retrieve (AONE bs) Void = bs" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
320 |
| "retrieve (ACHAR bs c) (Char d) = bs" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
321 |
| "retrieve (AALT bs r1 r2) (Left v) = bs @ retrieve r1 v" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
322 |
| "retrieve (AALT bs r1 r2) (Right v) = bs @ retrieve r2 v" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
323 |
| "retrieve (ASEQ bs r1 r2) (Seq v1 v2) = bs @ retrieve r1 v1 @ retrieve r2 v2" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
324 |
| "retrieve (ASTAR bs r) (Stars []) = bs @ [True]" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
325 |
| "retrieve (ASTAR bs r) (Stars (v#vs)) = |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
326 |
bs @ [False] @ retrieve r v @ retrieve (ASTAR [] r) (Stars vs)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
327 |
|
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
328 |
fun |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
329 |
anullable :: "arexp \<Rightarrow> bool" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
330 |
where |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
331 |
"anullable (AZERO) = False" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
332 |
| "anullable (AONE bs) = True" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
333 |
| "anullable (ACHAR bs c) = False" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
334 |
| "anullable (AALT bs r1 r2) = (anullable r1 \<or> anullable r2)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
335 |
| "anullable (ASEQ bs r1 r2) = (anullable r1 \<and> anullable r2)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
336 |
| "anullable (ASTAR bs r) = True" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
337 |
|
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
338 |
fun |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
339 |
amkeps :: "arexp \<Rightarrow> bool list" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
340 |
where |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
341 |
"amkeps(AONE bs) = bs" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
342 |
| "amkeps(ASEQ bs r1 r2) = bs @ (amkeps r1) @ (amkeps r2)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
343 |
| "amkeps(AALT bs r1 r2) = (if anullable(r1) then bs @ (amkeps r1) else bs @ (amkeps r2))" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
344 |
| "amkeps(ASTAR bs r) = bs @ [True]" |
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
345 |
|
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
346 |
|
159
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
347 |
fun |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
348 |
ader :: "char \<Rightarrow> arexp \<Rightarrow> arexp" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
349 |
where |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
350 |
"ader c (AZERO) = AZERO" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
351 |
| "ader c (AONE bs) = AZERO" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
352 |
| "ader c (ACHAR bs d) = (if c = d then AONE bs else AZERO)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
353 |
| "ader c (AALT bs r1 r2) = AALT bs (ader c r1) (ader c r2)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
354 |
| "ader c (ASEQ bs r1 r2) = |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
355 |
(if anullable r1 |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
356 |
then AALT bs (ASEQ [] (ader c r1) r2) (fuse (amkeps r1) (ader c r2)) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
357 |
else ASEQ bs (ader c r1) r2)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
358 |
| "ader c (ASTAR bs r) = ASEQ bs (fuse [False] (ader c r)) (ASTAR [] r)" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
359 |
|
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
360 |
lemma |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
361 |
assumes "\<turnstile> v : der c r" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
362 |
shows "Some (injval r c v) = decode (retrieve (ader c (internalise r)) v) r" |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
363 |
using assms |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
364 |
apply(induct c r arbitrary: v rule: der.induct) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
365 |
apply(simp_all) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
366 |
apply(erule Prf_elims) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
367 |
apply(erule Prf_elims) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
368 |
apply(case_tac "c = d") |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
369 |
apply(simp) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
370 |
apply(erule Prf_elims) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
371 |
apply(simp) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
372 |
apply(simp) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
373 |
apply(erule Prf_elims) |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
374 |
apply(auto split: prod.splits)[1] |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
375 |
oops |
940530087f30
updated programs
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
154
diff
changeset
|
376 |
|
148
702ed601349b
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff
changeset
|
377 |
end |