author | Christian Urban <urbanc@in.tum.de> |
Fri, 25 Aug 2017 23:52:49 +0200 | |
changeset 270 | 462d893ecb3d |
parent 269 | 12772d537b71 |
child 272 | f16019b11179 |
permissions | -rw-r--r-- |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
theory Positions |
268 | 3 |
imports "Spec" "Lexer" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
begin |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
6 |
section {* Positions in Values *} |
254 | 7 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
fun |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
at :: "val \<Rightarrow> nat list \<Rightarrow> val" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
"at v [] = v" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
| "at (Left v) (0#ps)= at v ps" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
| "at (Right v) (Suc 0#ps)= at v ps" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
| "at (Seq v1 v2) (0#ps)= at v1 ps" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
| "at (Seq v1 v2) (Suc 0#ps)= at v2 ps" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
| "at (Stars vs) (n#ps)= at (nth vs n) ps" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
18 |
|
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
19 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
fun Pos :: "val \<Rightarrow> (nat list) set" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
"Pos (Void) = {[]}" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
| "Pos (Char c) = {[]}" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
| "Pos (Left v) = {[]} \<union> {0#ps | ps. ps \<in> Pos v}" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
| "Pos (Right v) = {[]} \<union> {1#ps | ps. ps \<in> Pos v}" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
| "Pos (Seq v1 v2) = {[]} \<union> {0#ps | ps. ps \<in> Pos v1} \<union> {1#ps | ps. ps \<in> Pos v2}" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
| "Pos (Stars []) = {[]}" |
251 | 28 |
| "Pos (Stars (v#vs)) = {[]} \<union> {0#ps | ps. ps \<in> Pos v} \<union> {Suc n#ps | n ps. n#ps \<in> Pos (Stars vs)}" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
30 |
|
253 | 31 |
lemma Pos_stars: |
32 |
"Pos (Stars vs) = {[]} \<union> (\<Union>n < length vs. {n#ps | ps. ps \<in> Pos (vs ! n)})" |
|
33 |
apply(induct vs) |
|
267 | 34 |
apply(auto simp add: insert_ident less_Suc_eq_0_disj) |
35 |
done |
|
253 | 36 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
lemma Pos_empty: |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
shows "[] \<in> Pos v" |
251 | 39 |
by (induct v rule: Pos.induct)(auto) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
|
269 | 41 |
|
268 | 42 |
abbreviation |
43 |
"intlen vs \<equiv> int (length vs)" |
|
267 | 44 |
|
255 | 45 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
definition pflat_len :: "val \<Rightarrow> nat list => int" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
"pflat_len v p \<equiv> (if p \<in> Pos v then intlen (flat (at v p)) else -1)" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
lemma pflat_len_simps: |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
shows "pflat_len (Seq v1 v2) (0#p) = pflat_len v1 p" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
and "pflat_len (Seq v1 v2) (Suc 0#p) = pflat_len v2 p" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
and "pflat_len (Left v) (0#p) = pflat_len v p" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
and "pflat_len (Left v) (Suc 0#p) = -1" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
and "pflat_len (Right v) (Suc 0#p) = pflat_len v p" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
and "pflat_len (Right v) (0#p) = -1" |
251 | 57 |
and "pflat_len (Stars (v#vs)) (Suc n#p) = pflat_len (Stars vs) (n#p)" |
58 |
and "pflat_len (Stars (v#vs)) (0#p) = pflat_len v p" |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
and "pflat_len v [] = intlen (flat v)" |
251 | 60 |
by (auto simp add: pflat_len_def Pos_empty) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
lemma pflat_len_Stars_simps: |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
assumes "n < length vs" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
shows "pflat_len (Stars vs) (n#p) = pflat_len (vs!n) p" |
267 | 65 |
using assms |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
apply(induct vs arbitrary: n p) |
251 | 67 |
apply(auto simp add: less_Suc_eq_0_disj pflat_len_simps) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
70 |
lemma pflat_len_outside: |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
71 |
assumes "p \<notin> Pos v1" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
72 |
shows "pflat_len v1 p = -1 " |
267 | 73 |
using assms by (simp add: pflat_len_def) |
74 |
||
252 | 75 |
|
76 |
||
77 |
section {* Orderings *} |
|
78 |
||
79 |
||
257 | 80 |
definition prefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubseteq>pre _" [60,59] 60) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
where |
252 | 82 |
"ps1 \<sqsubseteq>pre ps2 \<equiv> \<exists>ps'. ps1 @ps' = ps2" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
|
257 | 84 |
definition sprefix_list:: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" ("_ \<sqsubset>spre _" [60,59] 60) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
where |
252 | 86 |
"ps1 \<sqsubset>spre ps2 \<equiv> ps1 \<sqsubseteq>pre ps2 \<and> ps1 \<noteq> ps2" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
|
257 | 88 |
inductive lex_list :: "nat list \<Rightarrow> nat list \<Rightarrow> bool" ("_ \<sqsubset>lex _" [60,59] 60) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
where |
252 | 90 |
"[] \<sqsubset>lex (p#ps)" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
| "ps1 \<sqsubset>lex ps2 \<Longrightarrow> (p#ps1) \<sqsubset>lex (p#ps2)" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
| "p1 < p2 \<Longrightarrow> (p1#ps1) \<sqsubset>lex (p2#ps2)" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
lemma lex_irrfl: |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
fixes ps1 ps2 :: "nat list" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
assumes "ps1 \<sqsubset>lex ps2" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
shows "ps1 \<noteq> ps2" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
using assms |
257 | 99 |
by(induct rule: lex_list.induct)(auto) |
100 |
||
251 | 101 |
lemma lex_simps [simp]: |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
fixes xs ys :: "nat list" |
251 | 103 |
shows "[] \<sqsubset>lex ys \<longleftrightarrow> ys \<noteq> []" |
104 |
and "xs \<sqsubset>lex [] \<longleftrightarrow> False" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
105 |
and "(x # xs) \<sqsubset>lex (y # ys) \<longleftrightarrow> (x < y \<or> (x = y \<and> xs \<sqsubset>lex ys))" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
106 |
by (auto simp add: neq_Nil_conv elim: lex_list.cases intro: lex_list.intros) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
lemma lex_trans: |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
109 |
fixes ps1 ps2 ps3 :: "nat list" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
assumes "ps1 \<sqsubset>lex ps2" "ps2 \<sqsubset>lex ps3" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
shows "ps1 \<sqsubset>lex ps3" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
using assms |
264 | 113 |
by (induct arbitrary: ps3 rule: lex_list.induct) |
114 |
(auto elim: lex_list.cases) |
|
115 |
||
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
|
257 | 117 |
lemma lex_trichotomous: |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
fixes p q :: "nat list" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
shows "p = q \<or> p \<sqsubset>lex q \<or> q \<sqsubset>lex p" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
apply(induct p arbitrary: q) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
121 |
apply(auto elim: lex_list.cases) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
apply(case_tac q) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
apply(auto) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
125 |
|
254 | 126 |
|
127 |
||
128 |
||
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
129 |
section {* POSIX Ordering of Values According to Okui & Suzuki *} |
254 | 130 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
131 |
|
261 | 132 |
definition PosOrd:: "val \<Rightarrow> nat list \<Rightarrow> val \<Rightarrow> bool" ("_ \<sqsubset>val _ _" [60, 60, 59] 60) |
133 |
where |
|
264 | 134 |
"v1 \<sqsubset>val p v2 \<equiv> pflat_len v1 p > pflat_len v2 p \<and> |
135 |
(\<forall>q \<in> Pos v1 \<union> Pos v2. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q)" |
|
136 |
||
269 | 137 |
lemma test: |
138 |
shows "v1 \<sqsubset>val p v2 \<longleftrightarrow> |
|
139 |
pflat_len v1 p > pflat_len v2 p \<and> |
|
140 |
(\<forall>q \<in> Pos v1. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q) \<and> |
|
141 |
(\<forall>q \<in> Pos v2. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q)" |
|
142 |
unfolding PosOrd_def |
|
143 |
apply(auto) |
|
144 |
done |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
145 |
|
261 | 146 |
|
147 |
definition PosOrd_ex:: "val \<Rightarrow> val \<Rightarrow> bool" ("_ :\<sqsubset>val _" [60, 59] 60) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
where |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
149 |
"v1 :\<sqsubset>val v2 \<equiv> \<exists>p. v1 \<sqsubset>val p v2" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
151 |
definition PosOrd_ex_eq:: "val \<Rightarrow> val \<Rightarrow> bool" ("_ :\<sqsubseteq>val _" [60, 59] 60) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
"v1 :\<sqsubseteq>val v2 \<equiv> v1 :\<sqsubset>val v2 \<or> v1 = v2" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
155 |
|
268 | 156 |
lemma PosOrd_trans: |
157 |
assumes "v1 :\<sqsubset>val v2" "v2 :\<sqsubset>val v3" |
|
158 |
shows "v1 :\<sqsubset>val v3" |
|
159 |
proof - |
|
160 |
from assms obtain p p' |
|
161 |
where as: "v1 \<sqsubset>val p v2" "v2 \<sqsubset>val p' v3" unfolding PosOrd_ex_def by blast |
|
162 |
then have pos: "p \<in> Pos v1" "p' \<in> Pos v2" unfolding PosOrd_def pflat_len_def |
|
163 |
by (smt not_int_zless_negative)+ |
|
164 |
have "p = p' \<or> p \<sqsubset>lex p' \<or> p' \<sqsubset>lex p" |
|
165 |
by (rule lex_trichotomous) |
|
166 |
moreover |
|
167 |
{ assume "p = p'" |
|
168 |
with as have "v1 \<sqsubset>val p v3" unfolding PosOrd_def pflat_len_def |
|
169 |
by (smt Un_iff) |
|
170 |
then have " v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast |
|
171 |
} |
|
172 |
moreover |
|
173 |
{ assume "p \<sqsubset>lex p'" |
|
174 |
with as have "v1 \<sqsubset>val p v3" unfolding PosOrd_def pflat_len_def |
|
175 |
by (smt Un_iff lex_trans) |
|
176 |
then have " v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast |
|
177 |
} |
|
178 |
moreover |
|
179 |
{ assume "p' \<sqsubset>lex p" |
|
180 |
with as have "v1 \<sqsubset>val p' v3" unfolding PosOrd_def |
|
181 |
by (smt Un_iff lex_trans pflat_len_def) |
|
182 |
then have "v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast |
|
183 |
} |
|
184 |
ultimately show "v1 :\<sqsubset>val v3" by blast |
|
185 |
qed |
|
186 |
||
187 |
lemma PosOrd_irrefl: |
|
188 |
assumes "v :\<sqsubset>val v" |
|
189 |
shows "False" |
|
190 |
using assms unfolding PosOrd_ex_def PosOrd_def |
|
191 |
by auto |
|
192 |
||
193 |
lemma PosOrd_assym: |
|
194 |
assumes "v1 :\<sqsubset>val v2" |
|
195 |
shows "\<not>(v2 :\<sqsubset>val v1)" |
|
196 |
using assms |
|
197 |
using PosOrd_irrefl PosOrd_trans by blast |
|
198 |
||
199 |
text {* |
|
200 |
:\<sqsubseteq>val and :\<sqsubset>val are partial orders. |
|
201 |
*} |
|
202 |
||
203 |
lemma PosOrd_ordering: |
|
204 |
shows "ordering (\<lambda>v1 v2. v1 :\<sqsubseteq>val v2) (\<lambda> v1 v2. v1 :\<sqsubset>val v2)" |
|
205 |
unfolding ordering_def PosOrd_ex_eq_def |
|
206 |
apply(auto) |
|
207 |
using PosOrd_irrefl apply blast |
|
208 |
using PosOrd_assym apply blast |
|
209 |
using PosOrd_trans by blast |
|
210 |
||
211 |
lemma PosOrd_order: |
|
212 |
shows "class.order (\<lambda>v1 v2. v1 :\<sqsubseteq>val v2) (\<lambda> v1 v2. v1 :\<sqsubset>val v2)" |
|
213 |
using PosOrd_ordering |
|
214 |
apply(simp add: class.order_def class.preorder_def class.order_axioms_def) |
|
215 |
unfolding ordering_def |
|
216 |
by blast |
|
217 |
||
218 |
||
219 |
lemma PosOrd_ex_eq2: |
|
220 |
shows "v1 :\<sqsubset>val v2 \<longleftrightarrow> (v1 :\<sqsubseteq>val v2 \<and> v1 \<noteq> v2)" |
|
221 |
using PosOrd_ordering |
|
222 |
unfolding ordering_def |
|
223 |
by auto |
|
224 |
||
225 |
lemma PosOrdeq_trans: |
|
226 |
assumes "v1 :\<sqsubseteq>val v2" "v2 :\<sqsubseteq>val v3" |
|
227 |
shows "v1 :\<sqsubseteq>val v3" |
|
228 |
using assms PosOrd_ordering |
|
229 |
unfolding ordering_def |
|
230 |
by blast |
|
231 |
||
232 |
lemma PosOrdeq_antisym: |
|
233 |
assumes "v1 :\<sqsubseteq>val v2" "v2 :\<sqsubseteq>val v1" |
|
234 |
shows "v1 = v2" |
|
235 |
using assms PosOrd_ordering |
|
236 |
unfolding ordering_def |
|
237 |
by blast |
|
238 |
||
239 |
lemma PosOrdeq_refl: |
|
240 |
shows "v :\<sqsubseteq>val v" |
|
241 |
unfolding PosOrd_ex_eq_def |
|
242 |
by auto |
|
243 |
||
244 |
||
261 | 245 |
lemma PosOrd_shorterE: |
255 | 246 |
assumes "v1 :\<sqsubset>val v2" |
247 |
shows "length (flat v2) \<le> length (flat v1)" |
|
267 | 248 |
using assms unfolding PosOrd_ex_def PosOrd_def |
268 | 249 |
apply(auto simp add: pflat_len_def split: if_splits) |
267 | 250 |
apply (metis Pos_empty Un_iff at.simps(1) eq_iff lex_simps(1) nat_less_le) |
251 |
by (metis Pos_empty UnI2 at.simps(1) lex_simps(2) lex_trichotomous linear) |
|
255 | 252 |
|
261 | 253 |
lemma PosOrd_shorterI: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
254 |
assumes "length (flat v2) < length (flat v1)" |
268 | 255 |
shows "v1 :\<sqsubset>val v2" |
256 |
unfolding PosOrd_ex_def PosOrd_def pflat_len_def |
|
257 |
using assms Pos_empty by force |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
|
261 | 259 |
lemma PosOrd_spreI: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
260 |
assumes "flat v' \<sqsubset>spre flat v" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
shows "v :\<sqsubset>val v'" |
251 | 262 |
using assms |
261 | 263 |
apply(rule_tac PosOrd_shorterI) |
268 | 264 |
unfolding prefix_list_def sprefix_list_def |
265 |
by (metis append_Nil2 append_eq_conv_conj drop_all le_less_linear) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
266 |
|
269 | 267 |
lemma pflat_len_inside: |
268 |
assumes "pflat_len v2 p < pflat_len v1 p" |
|
269 |
shows "p \<in> Pos v1" |
|
270 |
using assms |
|
271 |
unfolding pflat_len_def |
|
272 |
by (auto split: if_splits) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
273 |
|
261 | 274 |
lemma PosOrd_Left_Right: |
275 |
assumes "flat v1 = flat v2" |
|
276 |
shows "Left v1 :\<sqsubset>val Right v2" |
|
277 |
unfolding PosOrd_ex_def |
|
278 |
apply(rule_tac x="[0]" in exI) |
|
269 | 279 |
apply(auto simp add: PosOrd_def pflat_len_simps assms) |
261 | 280 |
done |
256 | 281 |
|
269 | 282 |
lemma PosOrd_LeftE: |
283 |
assumes "Left v1 :\<sqsubset>val Left v2" "flat v1 = flat v2" |
|
284 |
shows "v1 :\<sqsubset>val v2" |
|
285 |
using assms |
|
286 |
unfolding PosOrd_ex_def test |
|
287 |
apply(auto simp add: pflat_len_simps) |
|
288 |
apply(frule pflat_len_inside) |
|
289 |
apply(auto simp add: pflat_len_simps) |
|
290 |
by (metis lex_simps(3) pflat_len_simps(3)) |
|
291 |
||
292 |
lemma PosOrd_LeftI: |
|
293 |
assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2" |
|
294 |
shows "Left v1 :\<sqsubset>val Left v2" |
|
295 |
using assms |
|
296 |
unfolding PosOrd_ex_def test |
|
297 |
apply(auto simp add: pflat_len_simps) |
|
298 |
by (metis less_numeral_extra(3) lex_simps(3) pflat_len_simps(3)) |
|
299 |
||
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
300 |
lemma PosOrd_Left_eq: |
269 | 301 |
assumes "flat v1 = flat v2" |
302 |
shows "Left v1 :\<sqsubset>val Left v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" |
|
303 |
using assms PosOrd_LeftE PosOrd_LeftI |
|
304 |
by blast |
|
305 |
||
306 |
||
307 |
lemma PosOrd_RightE: |
|
308 |
assumes "Right v1 :\<sqsubset>val Right v2" "flat v1 = flat v2" |
|
309 |
shows "v1 :\<sqsubset>val v2" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
310 |
using assms |
269 | 311 |
unfolding PosOrd_ex_def test |
312 |
apply(auto simp add: pflat_len_simps) |
|
313 |
apply(frule pflat_len_inside) |
|
314 |
apply(auto simp add: pflat_len_simps) |
|
315 |
by (metis lex_simps(3) pflat_len_simps(5)) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
316 |
|
261 | 317 |
lemma PosOrd_RightI: |
269 | 318 |
assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2" |
319 |
shows "Right v1 :\<sqsubset>val Right v2" |
|
252 | 320 |
using assms |
269 | 321 |
unfolding PosOrd_ex_def test |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
322 |
apply(auto simp add: pflat_len_simps) |
269 | 323 |
by (metis lex_simps(3) nat_neq_iff pflat_len_simps(5)) |
324 |
||
325 |
||
326 |
lemma PosOrd_Right_eq: |
|
327 |
assumes "flat v1 = flat v2" |
|
328 |
shows "Right v1 :\<sqsubset>val Right v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" |
|
329 |
using assms PosOrd_RightE PosOrd_RightI |
|
330 |
by blast |
|
252 | 331 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
332 |
|
261 | 333 |
lemma PosOrd_SeqI1: |
252 | 334 |
assumes "v1 :\<sqsubset>val v1'" "flat (Seq v1 v2) = flat (Seq v1' v2')" |
268 | 335 |
shows "Seq v1 v2 :\<sqsubset>val Seq v1' v2'" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
336 |
using assms(1) |
261 | 337 |
apply(subst (asm) PosOrd_ex_def) |
338 |
apply(subst (asm) PosOrd_def) |
|
252 | 339 |
apply(clarify) |
261 | 340 |
apply(subst PosOrd_ex_def) |
252 | 341 |
apply(rule_tac x="0#p" in exI) |
261 | 342 |
apply(subst PosOrd_def) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
343 |
apply(rule conjI) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
344 |
apply(simp add: pflat_len_simps) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
345 |
apply(rule ballI) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
346 |
apply(rule impI) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
347 |
apply(simp only: Pos.simps) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
348 |
apply(auto)[1] |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
349 |
apply(simp add: pflat_len_simps) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
350 |
using assms(2) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
351 |
apply(simp) |
268 | 352 |
apply(auto simp add: pflat_len_simps) |
353 |
by (metis length_append of_nat_add) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
354 |
|
261 | 355 |
lemma PosOrd_SeqI2: |
252 | 356 |
assumes "v2 :\<sqsubset>val v2'" "flat v2 = flat v2'" |
268 | 357 |
shows "Seq v v2 :\<sqsubset>val Seq v v2'" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
358 |
using assms(1) |
261 | 359 |
apply(subst (asm) PosOrd_ex_def) |
360 |
apply(subst (asm) PosOrd_def) |
|
252 | 361 |
apply(clarify) |
261 | 362 |
apply(subst PosOrd_ex_def) |
252 | 363 |
apply(rule_tac x="Suc 0#p" in exI) |
261 | 364 |
apply(subst PosOrd_def) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
365 |
apply(rule conjI) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
366 |
apply(simp add: pflat_len_simps) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
367 |
apply(rule ballI) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
368 |
apply(rule impI) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
369 |
apply(simp only: Pos.simps) |
252 | 370 |
apply(auto)[1] |
371 |
apply(simp add: pflat_len_simps) |
|
372 |
using assms(2) |
|
373 |
apply(simp) |
|
374 |
apply(auto simp add: pflat_len_simps) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
375 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
376 |
|
261 | 377 |
lemma PosOrd_SeqE: |
268 | 378 |
assumes "Seq v1 v2 :\<sqsubset>val Seq v1' v2'" |
254 | 379 |
shows "v1 :\<sqsubset>val v1' \<or> v2 :\<sqsubset>val v2'" |
380 |
using assms |
|
261 | 381 |
apply(simp add: PosOrd_ex_def) |
254 | 382 |
apply(erule exE) |
383 |
apply(case_tac p) |
|
261 | 384 |
apply(simp add: PosOrd_def) |
268 | 385 |
apply(auto simp add: pflat_len_simps)[1] |
254 | 386 |
apply(rule_tac x="[]" in exI) |
387 |
apply(drule_tac x="[]" in spec) |
|
388 |
apply(simp add: Pos_empty pflat_len_simps) |
|
389 |
apply(case_tac a) |
|
390 |
apply(rule disjI1) |
|
261 | 391 |
apply(simp add: PosOrd_def) |
268 | 392 |
apply(auto simp add: pflat_len_simps)[1] |
254 | 393 |
apply(rule_tac x="list" in exI) |
394 |
apply(simp) |
|
395 |
apply(rule ballI) |
|
396 |
apply(rule impI) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
397 |
apply(drule_tac x="0#q" in bspec) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
398 |
apply(simp) |
254 | 399 |
apply(simp add: pflat_len_simps) |
400 |
apply(case_tac nat) |
|
401 |
apply(rule disjI2) |
|
261 | 402 |
apply(simp add: PosOrd_def) |
268 | 403 |
apply(auto simp add: pflat_len_simps) |
254 | 404 |
apply(rule_tac x="list" in exI) |
405 |
apply(simp add: Pos_empty) |
|
406 |
apply(rule ballI) |
|
407 |
apply(rule impI) |
|
264 | 408 |
apply(auto)[1] |
254 | 409 |
apply(drule_tac x="Suc 0#q" in bspec) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
410 |
apply(simp) |
254 | 411 |
apply(simp add: pflat_len_simps) |
264 | 412 |
apply(drule_tac x="Suc 0#q" in bspec) |
413 |
apply(simp) |
|
414 |
apply(simp add: pflat_len_simps) |
|
415 |
apply(simp add: PosOrd_def pflat_len_def) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
416 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
417 |
|
261 | 418 |
lemma PosOrd_StarsI: |
268 | 419 |
assumes "v1 :\<sqsubset>val v2" "flats (v1#vs1) = flats (v2#vs2)" |
420 |
shows "Stars (v1#vs1) :\<sqsubset>val Stars (v2#vs2)" |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
421 |
using assms(1) |
261 | 422 |
apply(subst (asm) PosOrd_ex_def) |
423 |
apply(subst (asm) PosOrd_def) |
|
254 | 424 |
apply(clarify) |
261 | 425 |
apply(subst PosOrd_ex_def) |
426 |
apply(subst PosOrd_def) |
|
254 | 427 |
apply(rule_tac x="0#p" in exI) |
428 |
apply(simp add: pflat_len_Stars_simps pflat_len_simps) |
|
429 |
using assms(2) |
|
268 | 430 |
apply(simp add: pflat_len_simps) |
254 | 431 |
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps) |
268 | 432 |
by (metis length_append of_nat_add) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
433 |
|
261 | 434 |
lemma PosOrd_StarsI2: |
268 | 435 |
assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flats vs1 = flats vs2" |
436 |
shows "Stars (v#vs1) :\<sqsubset>val Stars (v#vs2)" |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
437 |
using assms(1) |
261 | 438 |
apply(subst (asm) PosOrd_ex_def) |
439 |
apply(subst (asm) PosOrd_def) |
|
254 | 440 |
apply(clarify) |
261 | 441 |
apply(subst PosOrd_ex_def) |
442 |
apply(subst PosOrd_def) |
|
254 | 443 |
apply(case_tac p) |
444 |
apply(simp add: pflat_len_simps) |
|
445 |
apply(rule_tac x="Suc a#list" in exI) |
|
268 | 446 |
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps assms(2)) |
254 | 447 |
done |
448 |
||
261 | 449 |
lemma PosOrd_Stars_appendI: |
254 | 450 |
assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flat (Stars vs1) = flat (Stars vs2)" |
451 |
shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)" |
|
452 |
using assms |
|
453 |
apply(induct vs) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
454 |
apply(simp) |
261 | 455 |
apply(simp add: PosOrd_StarsI2) |
254 | 456 |
done |
457 |
||
261 | 458 |
lemma PosOrd_StarsE2: |
254 | 459 |
assumes "Stars (v # vs1) :\<sqsubset>val Stars (v # vs2)" |
460 |
shows "Stars vs1 :\<sqsubset>val Stars vs2" |
|
461 |
using assms |
|
261 | 462 |
apply(subst (asm) PosOrd_ex_def) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
463 |
apply(erule exE) |
254 | 464 |
apply(case_tac p) |
465 |
apply(simp) |
|
268 | 466 |
apply(simp add: PosOrd_def pflat_len_simps) |
261 | 467 |
apply(subst PosOrd_ex_def) |
254 | 468 |
apply(rule_tac x="[]" in exI) |
261 | 469 |
apply(simp add: PosOrd_def pflat_len_simps Pos_empty) |
254 | 470 |
apply(simp) |
471 |
apply(case_tac a) |
|
472 |
apply(clarify) |
|
264 | 473 |
apply(auto simp add: pflat_len_simps PosOrd_def pflat_len_def split: if_splits)[1] |
254 | 474 |
apply(clarify) |
261 | 475 |
apply(simp add: PosOrd_ex_def) |
254 | 476 |
apply(rule_tac x="nat#list" in exI) |
268 | 477 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 478 |
apply(case_tac q) |
268 | 479 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 480 |
apply(clarify) |
481 |
apply(drule_tac x="Suc a # lista" in bspec) |
|
482 |
apply(simp) |
|
268 | 483 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 484 |
apply(case_tac q) |
268 | 485 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 486 |
apply(clarify) |
487 |
apply(drule_tac x="Suc a # lista" in bspec) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
488 |
apply(simp) |
268 | 489 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 490 |
done |
491 |
||
261 | 492 |
lemma PosOrd_Stars_appendE: |
254 | 493 |
assumes "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)" |
494 |
shows "Stars vs1 :\<sqsubset>val Stars vs2" |
|
495 |
using assms |
|
496 |
apply(induct vs) |
|
497 |
apply(simp) |
|
261 | 498 |
apply(simp add: PosOrd_StarsE2) |
254 | 499 |
done |
500 |
||
261 | 501 |
lemma PosOrd_Stars_append_eq: |
254 | 502 |
assumes "flat (Stars vs1) = flat (Stars vs2)" |
503 |
shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2) \<longleftrightarrow> Stars vs1 :\<sqsubset>val Stars vs2" |
|
504 |
using assms |
|
505 |
apply(rule_tac iffI) |
|
261 | 506 |
apply(erule PosOrd_Stars_appendE) |
507 |
apply(rule PosOrd_Stars_appendI) |
|
254 | 508 |
apply(auto) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
509 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
510 |
|
261 | 511 |
lemma PosOrd_almost_trichotomous: |
256 | 512 |
shows "v1 :\<sqsubset>val v2 \<or> v2 :\<sqsubset>val v1 \<or> (intlen (flat v1) = intlen (flat v2))" |
261 | 513 |
apply(auto simp add: PosOrd_ex_def) |
514 |
apply(auto simp add: PosOrd_def) |
|
256 | 515 |
apply(rule_tac x="[]" in exI) |
516 |
apply(auto simp add: Pos_empty pflat_len_simps) |
|
517 |
apply(drule_tac x="[]" in spec) |
|
518 |
apply(auto simp add: Pos_empty pflat_len_simps) |
|
519 |
done |
|
520 |
||
521 |
||
261 | 522 |
lemma PosOrd_SeqE2: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
523 |
assumes "(Seq v1 v2) :\<sqsubset>val (Seq v1' v2')" "flat (Seq v1 v2) = flat (Seq v1' v2')" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
524 |
shows "v1 :\<sqsubset>val v1' \<or> (intlen (flat v1) = intlen (flat v1') \<and> v2 :\<sqsubset>val v2')" |
256 | 525 |
using assms |
261 | 526 |
apply(frule_tac PosOrd_SeqE) |
256 | 527 |
apply(erule disjE) |
528 |
apply(simp) |
|
529 |
apply(case_tac "v1 :\<sqsubset>val v1'") |
|
530 |
apply(simp) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
531 |
apply(rule disjI2) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
532 |
apply(rule conjI) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
533 |
prefer 2 |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
534 |
apply(simp) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
535 |
apply(auto) |
261 | 536 |
apply(auto simp add: PosOrd_ex_def) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
537 |
apply(auto simp add: PosOrd_def pflat_len_simps) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
538 |
apply(case_tac p) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
539 |
apply(auto simp add: PosOrd_def pflat_len_simps) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
540 |
apply(case_tac a) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
541 |
apply(auto simp add: PosOrd_def pflat_len_simps) |
268 | 542 |
apply (metis PosOrd_SeqI1 PosOrd_def PosOrd_ex_def PosOrd_shorterI PosOrd_assym assms less_linear) |
543 |
by (metis PosOrd_SeqI1 PosOrd_almost_trichotomous PosOrd_def PosOrd_ex_def PosOrd_assym assms of_nat_eq_iff) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
544 |
|
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
545 |
lemma PosOrd_SeqE4: |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
546 |
assumes "(Seq v1 v2) :\<sqsubset>val (Seq v1' v2')" "flat (Seq v1 v2) = flat (Seq v1' v2')" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
547 |
shows "v1 :\<sqsubset>val v1' \<or> (flat v1 = flat v1' \<and> v2 :\<sqsubset>val v2')" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
548 |
using assms |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
549 |
apply(frule_tac PosOrd_SeqE) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
550 |
apply(erule disjE) |
256 | 551 |
apply(simp) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
552 |
apply(case_tac "v1 :\<sqsubset>val v1'") |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
553 |
apply(simp) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
554 |
apply(rule disjI2) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
555 |
apply(rule conjI) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
556 |
prefer 2 |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
557 |
apply(simp) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
558 |
apply(auto) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
559 |
apply(case_tac "length (flat v1') < length (flat v1)") |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
560 |
using PosOrd_shorterI apply blast |
268 | 561 |
by (metis PosOrd_SeqI1 PosOrd_shorterI PosOrd_assym antisym_conv3 append_eq_append_conv assms(2)) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
562 |
|
254 | 563 |
|
267 | 564 |
|
261 | 565 |
section {* The Posix Value is smaller than any other Value *} |
566 |
||
262 | 567 |
|
261 | 568 |
lemma Posix_PosOrd: |
268 | 569 |
assumes "s \<in> r \<rightarrow> v1" "v2 \<in> LV r s" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
570 |
shows "v1 :\<sqsubseteq>val v2" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
571 |
using assms |
261 | 572 |
proof (induct arbitrary: v2 rule: Posix.induct) |
573 |
case (Posix_ONE v) |
|
268 | 574 |
have "v \<in> LV ONE []" by fact |
262 | 575 |
then have "v = Void" |
268 | 576 |
by (simp add: LV_simps) |
261 | 577 |
then show "Void :\<sqsubseteq>val v" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
578 |
by (simp add: PosOrd_ex_eq_def) |
261 | 579 |
next |
580 |
case (Posix_CHAR c v) |
|
268 | 581 |
have "v \<in> LV (CHAR c) [c]" by fact |
262 | 582 |
then have "v = Char c" |
268 | 583 |
by (simp add: LV_simps) |
261 | 584 |
then show "Char c :\<sqsubseteq>val v" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
585 |
by (simp add: PosOrd_ex_eq_def) |
261 | 586 |
next |
587 |
case (Posix_ALT1 s r1 v r2 v2) |
|
588 |
have as1: "s \<in> r1 \<rightarrow> v" by fact |
|
268 | 589 |
have IH: "\<And>v2. v2 \<in> LV r1 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
590 |
have "v2 \<in> LV (ALT r1 r2) s" by fact |
|
262 | 591 |
then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
268 | 592 |
by(auto simp add: LV_def prefix_list_def) |
261 | 593 |
then consider |
262 | 594 |
(Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
595 |
| (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
|
268 | 596 |
by (auto elim: Prf.cases) |
261 | 597 |
then show "Left v :\<sqsubseteq>val v2" |
598 |
proof(cases) |
|
599 |
case (Left v3) |
|
268 | 600 |
have "v3 \<in> LV r1 s" using Left(2,3) |
601 |
by (auto simp add: LV_def prefix_list_def) |
|
261 | 602 |
with IH have "v :\<sqsubseteq>val v3" by simp |
603 |
moreover |
|
262 | 604 |
have "flat v3 = flat v" using as1 Left(3) |
605 |
by (simp add: Posix1(2)) |
|
261 | 606 |
ultimately have "Left v :\<sqsubseteq>val Left v3" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
607 |
by (simp add: PosOrd_ex_eq_def PosOrd_Left_eq) |
261 | 608 |
then show "Left v :\<sqsubseteq>val v2" unfolding Left . |
609 |
next |
|
610 |
case (Right v3) |
|
262 | 611 |
have "flat v3 = flat v" using as1 Right(3) |
612 |
by (simp add: Posix1(2)) |
|
268 | 613 |
then have "Left v :\<sqsubseteq>val Right v3" |
614 |
unfolding PosOrd_ex_eq_def |
|
615 |
by (simp add: PosOrd_Left_Right) |
|
261 | 616 |
then show "Left v :\<sqsubseteq>val v2" unfolding Right . |
617 |
qed |
|
618 |
next |
|
619 |
case (Posix_ALT2 s r2 v r1 v2) |
|
620 |
have as1: "s \<in> r2 \<rightarrow> v" by fact |
|
621 |
have as2: "s \<notin> L r1" by fact |
|
268 | 622 |
have IH: "\<And>v2. v2 \<in> LV r2 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
623 |
have "v2 \<in> LV (ALT r1 r2) s" by fact |
|
262 | 624 |
then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
268 | 625 |
by(auto simp add: LV_def prefix_list_def) |
261 | 626 |
then consider |
262 | 627 |
(Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
628 |
| (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
|
268 | 629 |
by (auto elim: Prf.cases) |
261 | 630 |
then show "Right v :\<sqsubseteq>val v2" |
631 |
proof (cases) |
|
632 |
case (Right v3) |
|
268 | 633 |
have "v3 \<in> LV r2 s" using Right(2,3) |
634 |
by (auto simp add: LV_def prefix_list_def) |
|
261 | 635 |
with IH have "v :\<sqsubseteq>val v3" by simp |
636 |
moreover |
|
262 | 637 |
have "flat v3 = flat v" using as1 Right(3) |
638 |
by (simp add: Posix1(2)) |
|
261 | 639 |
ultimately have "Right v :\<sqsubseteq>val Right v3" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
640 |
by (auto simp add: PosOrd_ex_eq_def PosOrd_RightI) |
261 | 641 |
then show "Right v :\<sqsubseteq>val v2" unfolding Right . |
642 |
next |
|
643 |
case (Left v3) |
|
268 | 644 |
have "v3 \<in> LV r1 s" using Left(2,3) as2 |
645 |
by (auto simp add: LV_def prefix_list_def) |
|
262 | 646 |
then have "flat v3 = flat v \<and> \<Turnstile> v3 : r1" using as1 Left(3) |
268 | 647 |
by (simp add: Posix1(2) LV_def) |
262 | 648 |
then have "False" using as1 as2 Left |
268 | 649 |
by (auto simp add: Posix1(2) L_flat_Prf1) |
262 | 650 |
then show "Right v :\<sqsubseteq>val v2" by simp |
261 | 651 |
qed |
652 |
next |
|
653 |
case (Posix_SEQ s1 r1 v1 s2 r2 v2 v3) |
|
264 | 654 |
have "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" by fact+ |
655 |
then have as1: "s1 = flat v1" "s2 = flat v2" by (simp_all add: Posix1(2)) |
|
268 | 656 |
have IH1: "\<And>v3. v3 \<in> LV r1 s1 \<Longrightarrow> v1 :\<sqsubseteq>val v3" by fact |
657 |
have IH2: "\<And>v3. v3 \<in> LV r2 s2 \<Longrightarrow> v2 :\<sqsubseteq>val v3" by fact |
|
261 | 658 |
have cond: "\<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 |
268 | 659 |
have "v3 \<in> LV (SEQ r1 r2) (s1 @ s2)" by fact |
261 | 660 |
then obtain v3a v3b where eqs: |
661 |
"v3 = Seq v3a v3b" "\<Turnstile> v3a : r1" "\<Turnstile> v3b : r2" |
|
262 | 662 |
"flat v3a @ flat v3b = s1 @ s2" |
268 | 663 |
by (force simp add: prefix_list_def LV_def elim: Prf.cases) |
262 | 664 |
with cond have "flat v3a \<sqsubseteq>pre s1" unfolding prefix_list_def |
268 | 665 |
by (smt L_flat_Prf1 append_eq_append_conv2 append_self_conv) |
262 | 666 |
then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat v3b = s2)" using eqs |
667 |
by (simp add: sprefix_list_def append_eq_conv_conj) |
|
668 |
then have q2: "v1 :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat v3b = s2)" |
|
264 | 669 |
using PosOrd_spreI as1(1) eqs by blast |
268 | 670 |
then have "v1 :\<sqsubset>val v3a \<or> (v3a \<in> LV r1 s1 \<and> v3b \<in> LV r2 s2)" using eqs(2,3) |
671 |
by (auto simp add: LV_def) |
|
262 | 672 |
then have "v1 :\<sqsubset>val v3a \<or> (v1 :\<sqsubseteq>val v3a \<and> v2 :\<sqsubseteq>val v3b)" using IH1 IH2 by blast |
673 |
then have "Seq v1 v2 :\<sqsubseteq>val Seq v3a v3b" using eqs q2 as1 |
|
270 | 674 |
thm PosOrd_SeqI1 PosOrd_SeqI2 |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
675 |
unfolding PosOrd_ex_eq_def by (auto simp add: PosOrd_SeqI1 PosOrd_SeqI2) |
262 | 676 |
then show "Seq v1 v2 :\<sqsubseteq>val v3" unfolding eqs by blast |
261 | 677 |
next |
678 |
case (Posix_STAR1 s1 r v s2 vs v3) |
|
264 | 679 |
have "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" by fact+ |
680 |
then have as1: "s1 = flat v" "s2 = flat (Stars vs)" by (auto dest: Posix1(2)) |
|
268 | 681 |
have IH1: "\<And>v3. v3 \<in> LV r s1 \<Longrightarrow> v :\<sqsubseteq>val v3" by fact |
682 |
have IH2: "\<And>v3. v3 \<in> LV (STAR r) s2 \<Longrightarrow> Stars vs :\<sqsubseteq>val v3" by fact |
|
261 | 683 |
have cond: "\<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 |
684 |
have cond2: "flat v \<noteq> []" by fact |
|
268 | 685 |
have "v3 \<in> LV (STAR r) (s1 @ s2)" by fact |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
686 |
then consider |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
687 |
(NonEmpty) v3a vs3 where "v3 = Stars (v3a # vs3)" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
688 |
"\<Turnstile> v3a : r" "\<Turnstile> Stars vs3 : STAR r" |
262 | 689 |
"flat (Stars (v3a # vs3)) = s1 @ s2" |
261 | 690 |
| (Empty) "v3 = Stars []" |
268 | 691 |
unfolding LV_def |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
692 |
apply(auto) |
268 | 693 |
apply(erule Prf.cases) |
270 | 694 |
apply(auto) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
695 |
apply(case_tac vs) |
270 | 696 |
apply(auto intro: Prf.intros) |
697 |
done |
|
268 | 698 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" |
261 | 699 |
proof (cases) |
700 |
case (NonEmpty v3a vs3) |
|
262 | 701 |
have "flat (Stars (v3a # vs3)) = s1 @ s2" using NonEmpty(4) . |
702 |
with cond have "flat v3a \<sqsubseteq>pre s1" using NonEmpty(2,3) |
|
703 |
unfolding prefix_list_def |
|
268 | 704 |
by (smt L_flat_Prf1 append_Nil2 append_eq_append_conv2 flat.simps(7)) |
262 | 705 |
then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" using NonEmpty(4) |
706 |
by (simp add: sprefix_list_def append_eq_conv_conj) |
|
707 |
then have q2: "v :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" |
|
264 | 708 |
using PosOrd_spreI as1(1) NonEmpty(4) by blast |
268 | 709 |
then have "v :\<sqsubset>val v3a \<or> (v3a \<in> LV r s1 \<and> Stars vs3 \<in> LV (STAR r) s2)" |
710 |
using NonEmpty(2,3) by (auto simp add: LV_def) |
|
264 | 711 |
then have "v :\<sqsubset>val v3a \<or> (v :\<sqsubseteq>val v3a \<and> Stars vs :\<sqsubseteq>val Stars vs3)" using IH1 IH2 by blast |
712 |
then have "v :\<sqsubset>val v3a \<or> (v = v3a \<and> Stars vs :\<sqsubseteq>val Stars vs3)" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
713 |
unfolding PosOrd_ex_eq_def by auto |
262 | 714 |
then have "Stars (v # vs) :\<sqsubseteq>val Stars (v3a # vs3)" using NonEmpty(4) q2 as1 |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
715 |
unfolding PosOrd_ex_eq_def |
268 | 716 |
using PosOrd_StarsI PosOrd_StarsI2 by auto |
262 | 717 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" unfolding NonEmpty by blast |
261 | 718 |
next |
719 |
case Empty |
|
720 |
have "v3 = Stars []" by fact |
|
721 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
722 |
unfolding PosOrd_ex_eq_def using cond2 |
261 | 723 |
by (simp add: PosOrd_shorterI) |
724 |
qed |
|
725 |
next |
|
726 |
case (Posix_STAR2 r v2) |
|
268 | 727 |
have "v2 \<in> LV (STAR r) []" by fact |
262 | 728 |
then have "v2 = Stars []" |
268 | 729 |
unfolding LV_def by (auto elim: Prf.cases) |
261 | 730 |
then show "Stars [] :\<sqsubseteq>val v2" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
731 |
by (simp add: PosOrd_ex_eq_def) |
261 | 732 |
qed |
253 | 733 |
|
263 | 734 |
|
261 | 735 |
lemma Posix_PosOrd_reverse: |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
736 |
assumes "s \<in> r \<rightarrow> v1" |
268 | 737 |
shows "\<not>(\<exists>v2 \<in> LV r s. v2 :\<sqsubset>val v1)" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
738 |
using assms |
267 | 739 |
by (metis Posix_PosOrd less_irrefl PosOrd_def |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
740 |
PosOrd_ex_eq_def PosOrd_ex_def PosOrd_trans) |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
741 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
742 |
|
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
743 |
|
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
744 |
lemma PosOrd_Posix_Stars: |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
745 |
assumes "\<forall>v \<in> set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" |
267 | 746 |
and "\<not>(\<exists>vs2 \<in> LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val (Stars vs))" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
747 |
shows "(flat (Stars vs)) \<in> (STAR r) \<rightarrow> Stars vs" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
748 |
using assms |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
749 |
proof(induct vs) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
750 |
case Nil |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
751 |
show "flat (Stars []) \<in> STAR r \<rightarrow> Stars []" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
752 |
by(simp add: Posix.intros) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
753 |
next |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
754 |
case (Cons v vs) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
755 |
have IH: "\<lbrakk>\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []; |
267 | 756 |
\<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)\<rbrakk> |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
757 |
\<Longrightarrow> flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" by fact |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
758 |
have as2: "\<forall>v\<in>set (v # vs). flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" by fact |
267 | 759 |
have as3: "\<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars (v # vs))). vs2 :\<sqsubset>val Stars (v # vs))" by fact |
268 | 760 |
have "flat v \<in> r \<rightarrow> v" "flat v \<noteq> []" using as2 by auto |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
761 |
moreover |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
762 |
have "flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
763 |
proof (rule IH) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
764 |
show "\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" using as2 by simp |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
765 |
next |
267 | 766 |
show "\<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)" using as3 |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
767 |
apply(auto) |
267 | 768 |
apply(subst (asm) (2) LV_def) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
769 |
apply(auto) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
770 |
apply(erule Prf.cases) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
771 |
apply(simp_all) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
772 |
apply(drule_tac x="Stars (v # vs)" in bspec) |
268 | 773 |
apply(simp add: LV_def) |
774 |
using Posix_LV Prf.intros(6) calculation |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
775 |
apply(rule_tac Prf.intros) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
776 |
apply(simp add:) |
268 | 777 |
prefer 2 |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
778 |
apply (simp add: PosOrd_StarsI2) |
268 | 779 |
apply(drule Posix_LV) |
780 |
apply(simp add: LV_def) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
781 |
done |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
782 |
qed |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
783 |
moreover |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
784 |
have "flat v \<noteq> []" using as2 by simp |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
785 |
moreover |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
786 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = flat (Stars vs) \<and> flat v @ s\<^sub>3 \<in> L r \<and> s\<^sub>4 \<in> L (STAR r))" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
787 |
using as3 |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
788 |
apply(auto) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
789 |
apply(drule L_flat_Prf2) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
790 |
apply(erule exE) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
791 |
apply(simp only: L.simps[symmetric]) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
792 |
apply(drule L_flat_Prf2) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
793 |
apply(erule exE) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
794 |
apply(clarify) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
795 |
apply(rotate_tac 5) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
796 |
apply(erule Prf.cases) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
797 |
apply(simp_all) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
798 |
apply(clarify) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
799 |
apply(drule_tac x="Stars (va#vs)" in bspec) |
267 | 800 |
apply(auto simp add: LV_def)[1] |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
801 |
apply(rule Prf.intros) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
802 |
apply(simp) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
803 |
by (simp add: PosOrd_StarsI PosOrd_shorterI) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
804 |
ultimately show "flat (Stars (v # vs)) \<in> STAR r \<rightarrow> Stars (v # vs)" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
805 |
by (simp add: Posix.intros) |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
806 |
qed |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
807 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
808 |
|
254 | 809 |
|
261 | 810 |
section {* The Smallest Value is indeed the Posix Value *} |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
811 |
|
261 | 812 |
lemma PosOrd_Posix: |
268 | 813 |
assumes "v1 \<in> LV r s" "\<forall>v\<^sub>2 \<in> LV r s. \<not> v\<^sub>2 :\<sqsubset>val v1" |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
814 |
shows "s \<in> r \<rightarrow> v1" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
815 |
using assms |
261 | 816 |
proof(induct r arbitrary: s v1) |
817 |
case (ZERO s v1) |
|
268 | 818 |
have "v1 \<in> LV ZERO s" by fact |
819 |
then show "s \<in> ZERO \<rightarrow> v1" unfolding LV_def |
|
820 |
by (auto elim: Prf.cases) |
|
261 | 821 |
next |
822 |
case (ONE s v1) |
|
268 | 823 |
have "v1 \<in> LV ONE s" by fact |
270 | 824 |
then have "v1 = Void" "s = []" unfolding LV_def |
825 |
by(auto elim: Prf.cases) |
|
826 |
then show "s \<in> ONE \<rightarrow> v1" |
|
827 |
by(auto intro: Posix.intros) |
|
261 | 828 |
next |
829 |
case (CHAR c s v1) |
|
268 | 830 |
have "v1 \<in> LV (CHAR c) s" by fact |
831 |
then show "s \<in> CHAR c \<rightarrow> v1" unfolding LV_def |
|
832 |
by (auto elim!: Prf.cases intro: Posix.intros) |
|
261 | 833 |
next |
834 |
case (ALT r1 r2 s v1) |
|
268 | 835 |
have IH1: "\<And>s v1. \<lbrakk>v1 \<in> LV r1 s; \<forall>v2 \<in> LV r1 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r1 \<rightarrow> v1" by fact |
836 |
have IH2: "\<And>s v1. \<lbrakk>v1 \<in> LV r2 s; \<forall>v2 \<in> LV r2 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r2 \<rightarrow> v1" by fact |
|
270 | 837 |
have as1: "\<forall>v2 \<in> LV (ALT r1 r2) s. \<not> v2 :\<sqsubset>val v1" by fact |
268 | 838 |
have as2: "v1 \<in> LV (ALT r1 r2) s" by fact |
261 | 839 |
then consider |
840 |
(Left) v1' where |
|
841 |
"v1 = Left v1'" "s = flat v1'" |
|
268 | 842 |
"v1' \<in> LV r1 s" |
261 | 843 |
| (Right) v1' where |
844 |
"v1 = Right v1'" "s = flat v1'" |
|
268 | 845 |
"v1' \<in> LV r2 s" |
846 |
unfolding LV_def by (auto elim: Prf.cases) |
|
261 | 847 |
then show "s \<in> ALT r1 r2 \<rightarrow> v1" |
848 |
proof (cases) |
|
849 |
case (Left v1') |
|
270 | 850 |
have "v1' \<in> LV r1 s" using Left(3) . |
261 | 851 |
moreover |
267 | 852 |
have "\<forall>v2 \<in> LV r1 s. \<not> v2 :\<sqsubset>val v1'" using as1 |
270 | 853 |
unfolding Left(1,2) unfolding LV_def |
854 |
using Prf.intros(2) PosOrd_Left_eq by force |
|
261 | 855 |
ultimately have "s \<in> r1 \<rightarrow> v1'" using IH1 by simp |
856 |
then have "s \<in> ALT r1 r2 \<rightarrow> Left v1'" by (rule Posix.intros) |
|
857 |
then show "s \<in> ALT r1 r2 \<rightarrow> v1" using Left by simp |
|
858 |
next |
|
859 |
case (Right v1') |
|
270 | 860 |
have "v1' \<in> LV r2 s" using Right(3) . |
261 | 861 |
moreover |
267 | 862 |
have "\<forall>v2 \<in> LV r2 s. \<not> v2 :\<sqsubset>val v1'" using as1 |
863 |
unfolding LV_def Right using Prf.intros(3) PosOrd_RightI by force |
|
261 | 864 |
ultimately have "s \<in> r2 \<rightarrow> v1'" using IH2 by simp |
865 |
moreover |
|
866 |
{ assume "s \<in> L r1" |
|
267 | 867 |
then obtain v' where "v' \<in> LV r1 s" |
868 |
unfolding LV_def using L_flat_Prf2 by blast |
|
869 |
then have "Left v' \<in> LV (ALT r1 r2) s" |
|
870 |
unfolding LV_def by (auto intro: Prf.intros) |
|
261 | 871 |
with as1 have "\<not> (Left v' :\<sqsubset>val Right v1') \<and> (flat v' = s)" |
268 | 872 |
unfolding LV_def Right |
873 |
by (auto) |
|
261 | 874 |
then have False using PosOrd_Left_Right Right by blast |
875 |
} |
|
876 |
then have "s \<notin> L r1" by rule |
|
877 |
ultimately have "s \<in> ALT r1 r2 \<rightarrow> Right v1'" by (rule Posix.intros) |
|
878 |
then show "s \<in> ALT r1 r2 \<rightarrow> v1" using Right by simp |
|
879 |
qed |
|
880 |
next |
|
881 |
case (SEQ r1 r2 s v1) |
|
268 | 882 |
have IH1: "\<And>s v1. \<lbrakk>v1 \<in> LV r1 s; \<forall>v2 \<in> LV r1 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r1 \<rightarrow> v1" by fact |
883 |
have IH2: "\<And>s v1. \<lbrakk>v1 \<in> LV r2 s; \<forall>v2 \<in> LV r2 s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r2 \<rightarrow> v1" by fact |
|
267 | 884 |
have as1: "\<forall>v2\<in>LV (SEQ r1 r2) s. \<not> v2 :\<sqsubset>val v1" by fact |
268 | 885 |
have as2: "v1 \<in> LV (SEQ r1 r2) s" by fact |
261 | 886 |
then obtain |
887 |
v1a v1b where eqs: |
|
888 |
"v1 = Seq v1a v1b" "s = flat v1a @ flat v1b" |
|
268 | 889 |
"v1a \<in> LV r1 (flat v1a)" "v1b \<in> LV r2 (flat v1b)" |
890 |
unfolding LV_def by(auto elim: Prf.cases) |
|
267 | 891 |
have "\<forall>v2 \<in> LV r1 (flat v1a). \<not> v2 :\<sqsubset>val v1a" |
261 | 892 |
proof |
893 |
fix v2 |
|
267 | 894 |
assume "v2 \<in> LV r1 (flat v1a)" |
895 |
with eqs(2,4) have "Seq v2 v1b \<in> LV (SEQ r1 r2) s" |
|
268 | 896 |
by (simp add: LV_def Prf.intros(1)) |
261 | 897 |
with as1 have "\<not> Seq v2 v1b :\<sqsubset>val Seq v1a v1b \<and> flat (Seq v2 v1b) = flat (Seq v1a v1b)" |
267 | 898 |
using eqs by (simp add: LV_def) |
261 | 899 |
then show "\<not> v2 :\<sqsubset>val v1a" |
900 |
using PosOrd_SeqI1 by blast |
|
901 |
qed |
|
902 |
then have "flat v1a \<in> r1 \<rightarrow> v1a" using IH1 eqs by simp |
|
903 |
moreover |
|
267 | 904 |
have "\<forall>v2 \<in> LV r2 (flat v1b). \<not> v2 :\<sqsubset>val v1b" |
261 | 905 |
proof |
906 |
fix v2 |
|
267 | 907 |
assume "v2 \<in> LV r2 (flat v1b)" |
908 |
with eqs(2,3,4) have "Seq v1a v2 \<in> LV (SEQ r1 r2) s" |
|
268 | 909 |
by (simp add: LV_def Prf.intros) |
261 | 910 |
with as1 have "\<not> Seq v1a v2 :\<sqsubset>val Seq v1a v1b \<and> flat v2 = flat v1b" |
267 | 911 |
using eqs by (simp add: LV_def) |
261 | 912 |
then show "\<not> v2 :\<sqsubset>val v1b" |
913 |
using PosOrd_SeqI2 by auto |
|
914 |
qed |
|
915 |
then have "flat v1b \<in> r2 \<rightarrow> v1b" using IH2 eqs by simp |
|
916 |
moreover |
|
917 |
have "\<not> (\<exists>s\<^sub>3 s\<^sub>4. s\<^sub>3 \<noteq> [] \<and> s\<^sub>3 @ s\<^sub>4 = flat v1b \<and> flat v1a @ s\<^sub>3 \<in> L r1 \<and> s\<^sub>4 \<in> L r2)" |
|
918 |
proof |
|
919 |
assume "\<exists>s3 s4. s3 \<noteq> [] \<and> s3 @ s4 = flat v1b \<and> flat v1a @ s3 \<in> L r1 \<and> s4 \<in> L r2" |
|
920 |
then obtain s3 s4 where q1: "s3 \<noteq> [] \<and> s3 @ s4 = flat v1b \<and> flat v1a @ s3 \<in> L r1 \<and> s4 \<in> L r2" by blast |
|
268 | 921 |
then obtain vA vB where q2: "flat vA = flat v1a @ s3" "\<Turnstile> vA : r1" "flat vB = s4" "\<Turnstile> vB : r2" |
261 | 922 |
using L_flat_Prf2 by blast |
267 | 923 |
then have "Seq vA vB \<in> LV (SEQ r1 r2) s" unfolding eqs using q1 |
268 | 924 |
by (auto simp add: LV_def intro!: Prf.intros) |
261 | 925 |
with as1 have "\<not> Seq vA vB :\<sqsubset>val Seq v1a v1b" unfolding eqs by auto |
926 |
then have "\<not> vA :\<sqsubset>val v1a \<and> length (flat vA) > length (flat v1a)" using q1 q2 PosOrd_SeqI1 by auto |
|
927 |
then show "False" |
|
928 |
using PosOrd_shorterI by blast |
|
929 |
qed |
|
930 |
ultimately |
|
931 |
show "s \<in> SEQ r1 r2 \<rightarrow> v1" unfolding eqs |
|
932 |
by (rule Posix.intros) |
|
933 |
next |
|
934 |
case (STAR r s v1) |
|
268 | 935 |
have IH: "\<And>s v1. \<lbrakk>v1 \<in> LV r s; \<forall>v2\<in>LV r s. \<not> v2 :\<sqsubset>val v1\<rbrakk> \<Longrightarrow> s \<in> r \<rightarrow> v1" by fact |
267 | 936 |
have as1: "\<forall>v2\<in>LV (STAR r) s. \<not> v2 :\<sqsubset>val v1" by fact |
268 | 937 |
have as2: "v1 \<in> LV (STAR r) s" by fact |
261 | 938 |
then obtain |
939 |
vs where eqs: |
|
940 |
"v1 = Stars vs" "s = flat (Stars vs)" |
|
268 | 941 |
"\<forall>v \<in> set vs. v \<in> LV r (flat v)" |
942 |
unfolding LV_def by (auto elim: Prf.cases) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
943 |
have "\<forall>v\<in>set vs. flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" |
261 | 944 |
proof |
945 |
fix v |
|
946 |
assume a: "v \<in> set vs" |
|
947 |
then obtain pre post where e: "vs = pre @ [v] @ post" |
|
948 |
by (metis append_Cons append_Nil in_set_conv_decomp_first) |
|
267 | 949 |
then have q: "\<forall>v2\<in>LV (STAR r) s. \<not> v2 :\<sqsubset>val Stars (pre @ [v] @ post)" |
261 | 950 |
using as1 unfolding eqs by simp |
267 | 951 |
have "\<forall>v2\<in>LV r (flat v). \<not> v2 :\<sqsubset>val v" unfolding eqs |
261 | 952 |
proof (rule ballI, rule notI) |
953 |
fix v2 |
|
954 |
assume w: "v2 :\<sqsubset>val v" |
|
267 | 955 |
assume "v2 \<in> LV r (flat v)" |
956 |
then have "Stars (pre @ [v2] @ post) \<in> LV (STAR r) s" |
|
261 | 957 |
using as2 unfolding e eqs |
268 | 958 |
apply(auto simp add: LV_def intro!: Prf.intros elim: Prf_elims dest: Prf_Stars_appendE) |
959 |
apply(auto dest!: Prf_Stars_appendE elim: Prf.cases) |
|
960 |
done |
|
261 | 961 |
then have "\<not> Stars (pre @ [v2] @ post) :\<sqsubset>val Stars (pre @ [v] @ post)" |
962 |
using q by simp |
|
963 |
with w show "False" |
|
267 | 964 |
using LV_def \<open>v2 \<in> LV r (flat v)\<close> append_Cons flat.simps(7) mem_Collect_eq |
261 | 965 |
PosOrd_StarsI PosOrd_Stars_appendI by auto |
966 |
qed |
|
967 |
with IH |
|
268 | 968 |
show "flat v \<in> r \<rightarrow> v \<and> flat v \<noteq> []" using a as2 unfolding eqs LV_def |
969 |
by (auto elim: Prf.cases) |
|
261 | 970 |
qed |
971 |
moreover |
|
267 | 972 |
have "\<not> (\<exists>vs2\<in>LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs)" |
261 | 973 |
proof |
267 | 974 |
assume "\<exists>vs2 \<in> LV (STAR r) (flat (Stars vs)). vs2 :\<sqsubset>val Stars vs" |
268 | 975 |
then obtain vs2 where "\<Turnstile> Stars vs2 : STAR r" "flat (Stars vs2) = flat (Stars vs)" |
261 | 976 |
"Stars vs2 :\<sqsubset>val Stars vs" |
268 | 977 |
unfolding LV_def by (force elim: Prf_elims intro: Prf.intros) |
261 | 978 |
then show "False" using as1 unfolding eqs |
268 | 979 |
by (auto simp add: LV_def) |
261 | 980 |
qed |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
981 |
ultimately have "flat (Stars vs) \<in> STAR r \<rightarrow> Stars vs" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
982 |
thm PosOrd_Posix_Stars |
261 | 983 |
by (rule PosOrd_Posix_Stars) |
984 |
then show "s \<in> STAR r \<rightarrow> v1" unfolding eqs . |
|
985 |
qed |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
986 |
|
268 | 987 |
lemma Least_existence: |
988 |
assumes "LV r s \<noteq> {}" |
|
989 |
shows " \<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
|
990 |
proof - |
|
991 |
from assms |
|
992 |
obtain vposix where "s \<in> r \<rightarrow> vposix" |
|
993 |
unfolding LV_def |
|
994 |
using L_flat_Prf1 lexer_correct_Some by blast |
|
995 |
then have "\<forall>v \<in> LV r s. vposix :\<sqsubseteq>val v" |
|
996 |
by (simp add: Posix_PosOrd) |
|
997 |
then show "\<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
|
998 |
using Posix_LV \<open>s \<in> r \<rightarrow> vposix\<close> by blast |
|
999 |
qed |
|
1000 |
||
1001 |
lemma Least_existence1: |
|
1002 |
assumes "LV r s \<noteq> {}" |
|
1003 |
shows " \<exists>!vmin \<in> LV r s. \<forall>v \<in> (LV r s \<union> {v'. flat v' \<sqsubset>spre s}). vmin :\<sqsubseteq>val v" |
|
1004 |
using Least_existence[OF assms] assms |
|
1005 |
apply - |
|
1006 |
apply(erule bexE) |
|
1007 |
apply(rule_tac a="vmin" in ex1I) |
|
1008 |
apply(auto)[1] |
|
1009 |
apply (metis PosOrd_Posix PosOrd_ex_eq2 PosOrd_spreI PosOrdeq_antisym Posix1(2)) |
|
1010 |
apply(auto)[1] |
|
1011 |
apply(simp add: PosOrdeq_antisym) |
|
1012 |
done |
|
1013 |
||
1014 |
lemma |
|
1015 |
shows "partial_order_on UNIV {(v1, v2). v1 :\<sqsubseteq>val v2}" |
|
1016 |
apply(simp add: partial_order_on_def) |
|
1017 |
apply(simp add: preorder_on_def refl_on_def) |
|
1018 |
apply(simp add: PosOrdeq_refl) |
|
1019 |
apply(auto) |
|
1020 |
apply(rule transI) |
|
1021 |
apply(auto intro: PosOrdeq_trans)[1] |
|
1022 |
apply(rule antisymI) |
|
1023 |
apply(simp add: PosOrdeq_antisym) |
|
1024 |
done |
|
1025 |
||
1026 |
lemma |
|
1027 |
"wf {(v1, v2). v1 :\<sqsubset>val v2 \<and> v1 \<in> LV r s \<and> v2 \<in> LV r s}" |
|
1028 |
apply(rule finite_acyclic_wf) |
|
1029 |
prefer 2 |
|
1030 |
apply(simp add: acyclic_def) |
|
1031 |
apply(induct_tac rule: trancl.induct) |
|
1032 |
apply(auto)[1] |
|
1033 |
oops |
|
1034 |
||
1035 |
||
249 | 1036 |
unused_thms |
1037 |
||
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1038 |
end |