author | Chengsong |
Tue, 05 Jul 2022 00:42:06 +0100 | |
changeset 562 | 57e33978e55d |
parent 495 | f9cdc295ccf7 |
child 642 | 6c13f76c070b |
permissions | -rw-r--r-- |
495
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
1 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
2 |
theory PosixSpec |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
3 |
imports RegLangs |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
4 |
begin |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
5 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
6 |
section \<open>"Plain" Values\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
7 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
8 |
datatype val = |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
9 |
Void |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
10 |
| Char char |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
11 |
| Seq val val |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
12 |
| Right val |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
13 |
| Left val |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
14 |
| Stars "val list" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
15 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
16 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
17 |
section \<open>The string behind a value\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
18 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
19 |
fun |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
20 |
flat :: "val \<Rightarrow> string" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
21 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
22 |
"flat (Void) = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
23 |
| "flat (Char c) = [c]" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
24 |
| "flat (Left v) = flat v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
25 |
| "flat (Right v) = flat v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
26 |
| "flat (Seq v1 v2) = (flat v1) @ (flat v2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
27 |
| "flat (Stars []) = []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
28 |
| "flat (Stars (v#vs)) = (flat v) @ (flat (Stars vs))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
29 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
30 |
abbreviation |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
31 |
"flats vs \<equiv> concat (map flat vs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
32 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
33 |
lemma flat_Stars [simp]: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
34 |
"flat (Stars vs) = flats vs" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
35 |
by (induct vs) (auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
36 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
37 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
38 |
section \<open>Lexical Values\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
39 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
40 |
inductive |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
41 |
Prf :: "val \<Rightarrow> rexp \<Rightarrow> bool" ("\<Turnstile> _ : _" [100, 100] 100) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
42 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
43 |
"\<lbrakk>\<Turnstile> v1 : r1; \<Turnstile> v2 : r2\<rbrakk> \<Longrightarrow> \<Turnstile> Seq v1 v2 : SEQ r1 r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
44 |
| "\<Turnstile> v1 : r1 \<Longrightarrow> \<Turnstile> Left v1 : ALT r1 r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
45 |
| "\<Turnstile> v2 : r2 \<Longrightarrow> \<Turnstile> Right v2 : ALT r1 r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
46 |
| "\<Turnstile> Void : ONE" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
47 |
| "\<Turnstile> Char c : CH c" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
48 |
| "\<forall>v \<in> set vs. \<Turnstile> v : r \<and> flat v \<noteq> [] \<Longrightarrow> \<Turnstile> Stars vs : STAR r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
49 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
50 |
inductive_cases Prf_elims: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
51 |
"\<Turnstile> v : ZERO" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
52 |
"\<Turnstile> v : SEQ r1 r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
53 |
"\<Turnstile> v : ALT r1 r2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
54 |
"\<Turnstile> v : ONE" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
55 |
"\<Turnstile> v : CH c" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
56 |
"\<Turnstile> vs : STAR r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
57 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
58 |
lemma Prf_Stars_appendE: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
59 |
assumes "\<Turnstile> Stars (vs1 @ vs2) : STAR r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
60 |
shows "\<Turnstile> Stars vs1 : STAR r \<and> \<Turnstile> Stars vs2 : STAR r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
61 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
62 |
by (auto intro: Prf.intros elim!: Prf_elims) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
63 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
64 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
65 |
lemma flats_Prf_value: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
66 |
assumes "\<forall>s\<in>set ss. \<exists>v. s = flat v \<and> \<Turnstile> v : r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
67 |
shows "\<exists>vs. flats vs = concat ss \<and> (\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> [])" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
68 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
69 |
apply(induct ss) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
70 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
71 |
apply(rule_tac x="[]" in exI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
72 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
73 |
apply(case_tac "flat v = []") |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
74 |
apply(rule_tac x="vs" in exI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
75 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
76 |
apply(rule_tac x="v#vs" in exI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
77 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
78 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
79 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
80 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
81 |
lemma L_flat_Prf1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
82 |
assumes "\<Turnstile> v : r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
83 |
shows "flat v \<in> L r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
84 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
85 |
by (induct) (auto simp add: Sequ_def Star_concat) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
86 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
87 |
lemma L_flat_Prf2: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
88 |
assumes "s \<in> L r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
89 |
shows "\<exists>v. \<Turnstile> v : r \<and> flat v = s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
90 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
91 |
proof(induct r arbitrary: s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
92 |
case (STAR r s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
93 |
have IH: "\<And>s. s \<in> L r \<Longrightarrow> \<exists>v. \<Turnstile> v : r \<and> flat v = s" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
94 |
have "s \<in> L (STAR r)" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
95 |
then obtain ss where "concat ss = s" "\<forall>s \<in> set ss. s \<in> L r \<and> s \<noteq> []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
96 |
using Star_split by auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
97 |
then obtain vs where "flats vs = s" "\<forall>v\<in>set vs. \<Turnstile> v : r \<and> flat v \<noteq> []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
98 |
using IH flats_Prf_value by metis |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
99 |
then show "\<exists>v. \<Turnstile> v : STAR r \<and> flat v = s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
100 |
using Prf.intros(6) flat_Stars by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
101 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
102 |
case (SEQ r1 r2 s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
103 |
then show "\<exists>v. \<Turnstile> v : SEQ r1 r2 \<and> flat v = s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
104 |
unfolding Sequ_def L.simps by (fastforce intro: Prf.intros) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
105 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
106 |
case (ALT r1 r2 s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
107 |
then show "\<exists>v. \<Turnstile> v : ALT r1 r2 \<and> flat v = s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
108 |
unfolding L.simps by (fastforce intro: Prf.intros) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
109 |
qed (auto intro: Prf.intros) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
110 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
111 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
112 |
lemma L_flat_Prf: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
113 |
shows "L(r) = {flat v | v. \<Turnstile> v : r}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
114 |
using L_flat_Prf1 L_flat_Prf2 by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
115 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
116 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
117 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
118 |
section \<open>Sets of Lexical Values\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
119 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
120 |
text \<open> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
121 |
Shows that lexical values are finite for a given regex and string. |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
122 |
\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
123 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
124 |
definition |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
125 |
LV :: "rexp \<Rightarrow> string \<Rightarrow> val set" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
126 |
where "LV r s \<equiv> {v. \<Turnstile> v : r \<and> flat v = s}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
127 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
128 |
lemma LV_simps: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
129 |
shows "LV ZERO s = {}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
130 |
and "LV ONE s = (if s = [] then {Void} else {})" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
131 |
and "LV (CH c) s = (if s = [c] then {Char c} else {})" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
132 |
and "LV (ALT r1 r2) s = Left ` LV r1 s \<union> Right ` LV r2 s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
133 |
unfolding LV_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
134 |
by (auto intro: Prf.intros elim: Prf.cases) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
135 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
136 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
137 |
abbreviation |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
138 |
"Prefixes s \<equiv> {s'. prefix s' s}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
139 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
140 |
abbreviation |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
141 |
"Suffixes s \<equiv> {s'. suffix s' s}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
142 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
143 |
abbreviation |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
144 |
"SSuffixes s \<equiv> {s'. strict_suffix s' s}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
145 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
146 |
lemma Suffixes_cons [simp]: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
147 |
shows "Suffixes (c # s) = Suffixes s \<union> {c # s}" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
148 |
by (auto simp add: suffix_def Cons_eq_append_conv) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
149 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
150 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
151 |
lemma finite_Suffixes: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
152 |
shows "finite (Suffixes s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
153 |
by (induct s) (simp_all) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
154 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
155 |
lemma finite_SSuffixes: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
156 |
shows "finite (SSuffixes s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
157 |
proof - |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
158 |
have "SSuffixes s \<subseteq> Suffixes s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
159 |
unfolding strict_suffix_def suffix_def by auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
160 |
then show "finite (SSuffixes s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
161 |
using finite_Suffixes finite_subset by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
162 |
qed |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
163 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
164 |
lemma finite_Prefixes: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
165 |
shows "finite (Prefixes s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
166 |
proof - |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
167 |
have "finite (Suffixes (rev s))" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
168 |
by (rule finite_Suffixes) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
169 |
then have "finite (rev ` Suffixes (rev s))" by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
170 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
171 |
have "rev ` (Suffixes (rev s)) = Prefixes s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
172 |
unfolding suffix_def prefix_def image_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
173 |
by (auto)(metis rev_append rev_rev_ident)+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
174 |
ultimately show "finite (Prefixes s)" by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
175 |
qed |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
176 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
177 |
lemma LV_STAR_finite: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
178 |
assumes "\<forall>s. finite (LV r s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
179 |
shows "finite (LV (STAR r) s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
180 |
proof(induct s rule: length_induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
181 |
fix s::"char list" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
182 |
assume "\<forall>s'. length s' < length s \<longrightarrow> finite (LV (STAR r) s')" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
183 |
then have IH: "\<forall>s' \<in> SSuffixes s. finite (LV (STAR r) s')" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
184 |
by (force simp add: strict_suffix_def suffix_def) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
185 |
define f where "f \<equiv> \<lambda>(v, vs). Stars (v # vs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
186 |
define S1 where "S1 \<equiv> \<Union>s' \<in> Prefixes s. LV r s'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
187 |
define S2 where "S2 \<equiv> \<Union>s2 \<in> SSuffixes s. Stars -` (LV (STAR r) s2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
188 |
have "finite S1" using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
189 |
unfolding S1_def by (simp_all add: finite_Prefixes) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
190 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
191 |
with IH have "finite S2" unfolding S2_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
192 |
by (auto simp add: finite_SSuffixes inj_on_def finite_vimageI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
193 |
ultimately |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
194 |
have "finite ({Stars []} \<union> f ` (S1 \<times> S2))" by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
195 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
196 |
have "LV (STAR r) s \<subseteq> {Stars []} \<union> f ` (S1 \<times> S2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
197 |
unfolding S1_def S2_def f_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
198 |
unfolding LV_def image_def prefix_def strict_suffix_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
199 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
200 |
apply(case_tac x) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
201 |
apply(auto elim: Prf_elims) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
202 |
apply(erule Prf_elims) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
203 |
apply(auto) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
204 |
apply(case_tac vs) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
205 |
apply(auto intro: Prf.intros) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
206 |
apply(rule exI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
207 |
apply(rule conjI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
208 |
apply(rule_tac x="flat a" in exI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
209 |
apply(rule conjI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
210 |
apply(rule_tac x="flats list" in exI) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
211 |
apply(simp) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
212 |
apply(blast) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
213 |
apply(simp add: suffix_def) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
214 |
using Prf.intros(6) by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
215 |
ultimately |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
216 |
show "finite (LV (STAR r) s)" by (simp add: finite_subset) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
217 |
qed |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
218 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
219 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
220 |
lemma LV_finite: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
221 |
shows "finite (LV r s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
222 |
proof(induct r arbitrary: s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
223 |
case (ZERO s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
224 |
show "finite (LV ZERO s)" by (simp add: LV_simps) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
225 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
226 |
case (ONE s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
227 |
show "finite (LV ONE s)" by (simp add: LV_simps) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
228 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
229 |
case (CH c s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
230 |
show "finite (LV (CH c) s)" by (simp add: LV_simps) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
231 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
232 |
case (ALT r1 r2 s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
233 |
then show "finite (LV (ALT r1 r2) s)" by (simp add: LV_simps) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
234 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
235 |
case (SEQ r1 r2 s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
236 |
define f where "f \<equiv> \<lambda>(v1, v2). Seq v1 v2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
237 |
define S1 where "S1 \<equiv> \<Union>s' \<in> Prefixes s. LV r1 s'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
238 |
define S2 where "S2 \<equiv> \<Union>s' \<in> Suffixes s. LV r2 s'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
239 |
have IHs: "\<And>s. finite (LV r1 s)" "\<And>s. finite (LV r2 s)" by fact+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
240 |
then have "finite S1" "finite S2" unfolding S1_def S2_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
241 |
by (simp_all add: finite_Prefixes finite_Suffixes) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
242 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
243 |
have "LV (SEQ r1 r2) s \<subseteq> f ` (S1 \<times> S2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
244 |
unfolding f_def S1_def S2_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
245 |
unfolding LV_def image_def prefix_def suffix_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
246 |
apply (auto elim!: Prf_elims) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
247 |
by (metis (mono_tags, lifting) mem_Collect_eq) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
248 |
ultimately |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
249 |
show "finite (LV (SEQ r1 r2) s)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
250 |
by (simp add: finite_subset) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
251 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
252 |
case (STAR r s) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
253 |
then show "finite (LV (STAR r) s)" by (simp add: LV_STAR_finite) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
254 |
qed |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
255 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
256 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
257 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
258 |
section \<open>Our inductive POSIX Definition\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
259 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
260 |
inductive |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
261 |
Posix :: "string \<Rightarrow> rexp \<Rightarrow> val \<Rightarrow> bool" ("_ \<in> _ \<rightarrow> _" [100, 100, 100] 100) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
262 |
where |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
263 |
Posix_ONE: "[] \<in> ONE \<rightarrow> Void" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
264 |
| Posix_CH: "[c] \<in> (CH c) \<rightarrow> (Char c)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
265 |
| Posix_ALT1: "s \<in> r1 \<rightarrow> v \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Left v)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
266 |
| Posix_ALT2: "\<lbrakk>s \<in> r2 \<rightarrow> v; s \<notin> L(r1)\<rbrakk> \<Longrightarrow> s \<in> (ALT r1 r2) \<rightarrow> (Right v)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
267 |
| Posix_SEQ: "\<lbrakk>s1 \<in> r1 \<rightarrow> v1; s2 \<in> r2 \<rightarrow> v2; |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
268 |
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r1 \<and> s\<^sub>4 \<in> L r2)\<rbrakk> \<Longrightarrow> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
269 |
(s1 @ s2) \<in> (SEQ r1 r2) \<rightarrow> (Seq v1 v2)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
270 |
| Posix_STAR1: "\<lbrakk>s1 \<in> r \<rightarrow> v; s2 \<in> STAR r \<rightarrow> Stars vs; flat v \<noteq> []; |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
271 |
\<not>(\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> (s1 @ s\<^sub>3) \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))\<rbrakk> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
272 |
\<Longrightarrow> (s1 @ s2) \<in> STAR r \<rightarrow> Stars (v # vs)" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
273 |
| Posix_STAR2: "[] \<in> STAR r \<rightarrow> Stars []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
274 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
275 |
inductive_cases Posix_elims: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
276 |
"s \<in> ZERO \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
277 |
"s \<in> ONE \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
278 |
"s \<in> CH c \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
279 |
"s \<in> ALT r1 r2 \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
280 |
"s \<in> SEQ r1 r2 \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
281 |
"s \<in> STAR r \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
282 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
283 |
lemma Posix1: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
284 |
assumes "s \<in> r \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
285 |
shows "s \<in> L r" "flat v = s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
286 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
287 |
by(induct s r v rule: Posix.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
288 |
(auto simp add: Sequ_def) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
289 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
290 |
text \<open> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
291 |
For a give value and string, our Posix definition |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
292 |
determines a unique value. |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
293 |
\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
294 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
295 |
lemma Posix_determ: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
296 |
assumes "s \<in> r \<rightarrow> v1" "s \<in> r \<rightarrow> v2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
297 |
shows "v1 = v2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
298 |
using assms |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
299 |
proof (induct s r v1 arbitrary: v2 rule: Posix.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
300 |
case (Posix_ONE v2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
301 |
have "[] \<in> ONE \<rightarrow> v2" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
302 |
then show "Void = v2" by cases auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
303 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
304 |
case (Posix_CH c v2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
305 |
have "[c] \<in> CH c \<rightarrow> v2" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
306 |
then show "Char c = v2" by cases auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
307 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
308 |
case (Posix_ALT1 s r1 v r2 v2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
309 |
have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
310 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
311 |
have "s \<in> r1 \<rightarrow> v" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
312 |
then have "s \<in> L r1" by (simp add: Posix1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
313 |
ultimately obtain v' where eq: "v2 = Left v'" "s \<in> r1 \<rightarrow> v'" by cases auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
314 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
315 |
have IH: "\<And>v2. s \<in> r1 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
316 |
ultimately have "v = v'" by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
317 |
then show "Left v = v2" using eq by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
318 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
319 |
case (Posix_ALT2 s r2 v r1 v2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
320 |
have "s \<in> ALT r1 r2 \<rightarrow> v2" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
321 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
322 |
have "s \<notin> L r1" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
323 |
ultimately obtain v' where eq: "v2 = Right v'" "s \<in> r2 \<rightarrow> v'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
324 |
by cases (auto simp add: Posix1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
325 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
326 |
have IH: "\<And>v2. s \<in> r2 \<rightarrow> v2 \<Longrightarrow> v = v2" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
327 |
ultimately have "v = v'" by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
328 |
then show "Right v = v2" using eq by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
329 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
330 |
case (Posix_SEQ s1 r1 v1 s2 r2 v2 v') |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
331 |
have "(s1 @ s2) \<in> SEQ r1 r2 \<rightarrow> v'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
332 |
"s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
333 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" by fact+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
334 |
then obtain v1' v2' where "v' = Seq v1' v2'" "s1 \<in> r1 \<rightarrow> v1'" "s2 \<in> r2 \<rightarrow> v2'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
335 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
336 |
using Posix1(1) by fastforce+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
337 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
338 |
have IHs: "\<And>v1'. s1 \<in> r1 \<rightarrow> v1' \<Longrightarrow> v1 = v1'" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
339 |
"\<And>v2'. s2 \<in> r2 \<rightarrow> v2' \<Longrightarrow> v2 = v2'" by fact+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
340 |
ultimately show "Seq v1 v2 = v'" by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
341 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
342 |
case (Posix_STAR1 s1 r v s2 vs v2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
343 |
have "(s1 @ s2) \<in> STAR r \<rightarrow> v2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
344 |
"s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" "flat v \<noteq> []" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
345 |
"\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = s2 \<and> s1 @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" by fact+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
346 |
then obtain v' vs' where "v2 = Stars (v' # vs')" "s1 \<in> r \<rightarrow> v'" "s2 \<in> (STAR r) \<rightarrow> (Stars vs')" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
347 |
apply(cases) apply (auto simp add: append_eq_append_conv2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
348 |
using Posix1(1) apply fastforce |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
349 |
apply (metis Posix1(1) Posix_STAR1.hyps(6) append_Nil append_Nil2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
350 |
using Posix1(2) by blast |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
351 |
moreover |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
352 |
have IHs: "\<And>v2. s1 \<in> r \<rightarrow> v2 \<Longrightarrow> v = v2" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
353 |
"\<And>v2. s2 \<in> STAR r \<rightarrow> v2 \<Longrightarrow> Stars vs = v2" by fact+ |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
354 |
ultimately show "Stars (v # vs) = v2" by auto |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
355 |
next |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
356 |
case (Posix_STAR2 r v2) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
357 |
have "[] \<in> STAR r \<rightarrow> v2" by fact |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
358 |
then show "Stars [] = v2" by cases (auto simp add: Posix1) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
359 |
qed |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
360 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
361 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
362 |
text \<open> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
363 |
Our POSIX values are lexical values. |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
364 |
\<close> |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
365 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
366 |
lemma Posix_LV: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
367 |
assumes "s \<in> r \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
368 |
shows "v \<in> LV r s" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
369 |
using assms unfolding LV_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
370 |
apply(induct rule: Posix.induct) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
371 |
apply(auto simp add: intro!: Prf.intros elim!: Prf_elims) |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
372 |
done |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
373 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
374 |
lemma Posix_Prf: |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
375 |
assumes "s \<in> r \<rightarrow> v" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
376 |
shows "\<Turnstile> v : r" |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
377 |
using assms Posix_LV LV_def |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
378 |
by simp |
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
379 |
|
f9cdc295ccf7
a fresh directory with cleaned up code
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff
changeset
|
380 |
end |