author | Christian Urban <urbanc@in.tum.de> |
Wed, 06 Sep 2017 00:52:08 +0100 | |
changeset 273 | e85099ac4c6c |
parent 272 | f16019b11179 |
child 292 | d688a01b8f89 |
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 |
||
273 | 137 |
lemma PosOrd_def2: |
269 | 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 |
273 | 249 |
apply(auto) |
250 |
apply(case_tac p) |
|
251 |
apply(simp add: pflat_len_simps) |
|
252 |
apply(drule_tac x="[]" in bspec) |
|
253 |
apply(simp add: Pos_empty) |
|
254 |
apply(simp add: pflat_len_simps) |
|
255 |
done |
|
255 | 256 |
|
261 | 257 |
lemma PosOrd_shorterI: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
258 |
assumes "length (flat v2) < length (flat v1)" |
268 | 259 |
shows "v1 :\<sqsubset>val v2" |
260 |
unfolding PosOrd_ex_def PosOrd_def pflat_len_def |
|
261 |
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
|
262 |
|
261 | 263 |
lemma PosOrd_spreI: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
264 |
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
|
265 |
shows "v :\<sqsubset>val v'" |
251 | 266 |
using assms |
261 | 267 |
apply(rule_tac PosOrd_shorterI) |
268 | 268 |
unfolding prefix_list_def sprefix_list_def |
269 |
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
|
270 |
|
269 | 271 |
lemma pflat_len_inside: |
272 |
assumes "pflat_len v2 p < pflat_len v1 p" |
|
273 |
shows "p \<in> Pos v1" |
|
274 |
using assms |
|
275 |
unfolding pflat_len_def |
|
276 |
by (auto split: if_splits) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
277 |
|
273 | 278 |
|
261 | 279 |
lemma PosOrd_Left_Right: |
280 |
assumes "flat v1 = flat v2" |
|
281 |
shows "Left v1 :\<sqsubset>val Right v2" |
|
282 |
unfolding PosOrd_ex_def |
|
283 |
apply(rule_tac x="[0]" in exI) |
|
269 | 284 |
apply(auto simp add: PosOrd_def pflat_len_simps assms) |
261 | 285 |
done |
256 | 286 |
|
269 | 287 |
lemma PosOrd_LeftE: |
288 |
assumes "Left v1 :\<sqsubset>val Left v2" "flat v1 = flat v2" |
|
289 |
shows "v1 :\<sqsubset>val v2" |
|
290 |
using assms |
|
273 | 291 |
unfolding PosOrd_ex_def PosOrd_def2 |
269 | 292 |
apply(auto simp add: pflat_len_simps) |
293 |
apply(frule pflat_len_inside) |
|
294 |
apply(auto simp add: pflat_len_simps) |
|
295 |
by (metis lex_simps(3) pflat_len_simps(3)) |
|
296 |
||
297 |
lemma PosOrd_LeftI: |
|
298 |
assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2" |
|
299 |
shows "Left v1 :\<sqsubset>val Left v2" |
|
300 |
using assms |
|
273 | 301 |
unfolding PosOrd_ex_def PosOrd_def2 |
269 | 302 |
apply(auto simp add: pflat_len_simps) |
303 |
by (metis less_numeral_extra(3) lex_simps(3) pflat_len_simps(3)) |
|
304 |
||
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
305 |
lemma PosOrd_Left_eq: |
269 | 306 |
assumes "flat v1 = flat v2" |
307 |
shows "Left v1 :\<sqsubset>val Left v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" |
|
308 |
using assms PosOrd_LeftE PosOrd_LeftI |
|
309 |
by blast |
|
310 |
||
311 |
||
312 |
lemma PosOrd_RightE: |
|
313 |
assumes "Right v1 :\<sqsubset>val Right v2" "flat v1 = flat v2" |
|
314 |
shows "v1 :\<sqsubset>val v2" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
315 |
using assms |
273 | 316 |
unfolding PosOrd_ex_def PosOrd_def2 |
269 | 317 |
apply(auto simp add: pflat_len_simps) |
318 |
apply(frule pflat_len_inside) |
|
319 |
apply(auto simp add: pflat_len_simps) |
|
320 |
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
|
321 |
|
261 | 322 |
lemma PosOrd_RightI: |
269 | 323 |
assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2" |
324 |
shows "Right v1 :\<sqsubset>val Right v2" |
|
252 | 325 |
using assms |
273 | 326 |
unfolding PosOrd_ex_def PosOrd_def2 |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
327 |
apply(auto simp add: pflat_len_simps) |
269 | 328 |
by (metis lex_simps(3) nat_neq_iff pflat_len_simps(5)) |
329 |
||
330 |
||
331 |
lemma PosOrd_Right_eq: |
|
332 |
assumes "flat v1 = flat v2" |
|
333 |
shows "Right v1 :\<sqsubset>val Right v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" |
|
334 |
using assms PosOrd_RightE PosOrd_RightI |
|
335 |
by blast |
|
252 | 336 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
337 |
|
261 | 338 |
lemma PosOrd_SeqI1: |
273 | 339 |
assumes "v1 :\<sqsubset>val w1" "flat (Seq v1 v2) = flat (Seq w1 w2)" |
340 |
shows "Seq v1 v2 :\<sqsubset>val Seq w1 w2" |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
341 |
using assms(1) |
261 | 342 |
apply(subst (asm) PosOrd_ex_def) |
343 |
apply(subst (asm) PosOrd_def) |
|
252 | 344 |
apply(clarify) |
261 | 345 |
apply(subst PosOrd_ex_def) |
252 | 346 |
apply(rule_tac x="0#p" in exI) |
261 | 347 |
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
|
348 |
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
|
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 |
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
|
351 |
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
|
352 |
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
|
353 |
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
|
354 |
apply(simp add: pflat_len_simps) |
273 | 355 |
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
|
356 |
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
|
357 |
apply(simp) |
273 | 358 |
apply(metis length_append of_nat_add) |
359 |
done |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
360 |
|
261 | 361 |
lemma PosOrd_SeqI2: |
273 | 362 |
assumes "v2 :\<sqsubset>val w2" "flat v2 = flat w2" |
363 |
shows "Seq v v2 :\<sqsubset>val Seq v w2" |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
364 |
using assms(1) |
261 | 365 |
apply(subst (asm) PosOrd_ex_def) |
366 |
apply(subst (asm) PosOrd_def) |
|
252 | 367 |
apply(clarify) |
261 | 368 |
apply(subst PosOrd_ex_def) |
252 | 369 |
apply(rule_tac x="Suc 0#p" in exI) |
261 | 370 |
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
|
371 |
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
|
372 |
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
|
373 |
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
|
374 |
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
|
375 |
apply(simp only: Pos.simps) |
252 | 376 |
apply(auto)[1] |
377 |
apply(simp add: pflat_len_simps) |
|
378 |
using assms(2) |
|
379 |
apply(simp) |
|
380 |
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
|
381 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
382 |
|
273 | 383 |
lemma PosOrd_Seq_eq: |
384 |
assumes "flat v2 = flat w2" |
|
385 |
shows "(Seq v v2) :\<sqsubset>val (Seq v w2) \<longleftrightarrow> v2 :\<sqsubset>val w2" |
|
386 |
using assms |
|
387 |
apply(auto) |
|
388 |
prefer 2 |
|
389 |
apply(simp add: PosOrd_SeqI2) |
|
261 | 390 |
apply(simp add: PosOrd_ex_def) |
273 | 391 |
apply(auto) |
254 | 392 |
apply(case_tac p) |
273 | 393 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 394 |
apply(case_tac a) |
273 | 395 |
apply(simp add: PosOrd_def pflat_len_simps) |
396 |
apply(clarify) |
|
397 |
apply(case_tac nat) |
|
398 |
prefer 2 |
|
399 |
apply(simp add: PosOrd_def pflat_len_simps pflat_len_outside) |
|
254 | 400 |
apply(rule_tac x="list" in exI) |
273 | 401 |
apply(auto simp add: PosOrd_def2 pflat_len_simps) |
402 |
apply(smt Collect_disj_eq lex_list.intros(2) mem_Collect_eq pflat_len_simps(2)) |
|
403 |
apply(smt Collect_disj_eq lex_list.intros(2) mem_Collect_eq pflat_len_simps(2)) |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
404 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
405 |
|
273 | 406 |
|
407 |
||
261 | 408 |
lemma PosOrd_StarsI: |
268 | 409 |
assumes "v1 :\<sqsubset>val v2" "flats (v1#vs1) = flats (v2#vs2)" |
410 |
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
|
411 |
using assms(1) |
261 | 412 |
apply(subst (asm) PosOrd_ex_def) |
413 |
apply(subst (asm) PosOrd_def) |
|
254 | 414 |
apply(clarify) |
261 | 415 |
apply(subst PosOrd_ex_def) |
416 |
apply(subst PosOrd_def) |
|
254 | 417 |
apply(rule_tac x="0#p" in exI) |
418 |
apply(simp add: pflat_len_Stars_simps pflat_len_simps) |
|
419 |
using assms(2) |
|
268 | 420 |
apply(simp add: pflat_len_simps) |
254 | 421 |
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps) |
268 | 422 |
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
|
423 |
|
261 | 424 |
lemma PosOrd_StarsI2: |
268 | 425 |
assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flats vs1 = flats vs2" |
426 |
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
|
427 |
using assms(1) |
261 | 428 |
apply(subst (asm) PosOrd_ex_def) |
429 |
apply(subst (asm) PosOrd_def) |
|
254 | 430 |
apply(clarify) |
261 | 431 |
apply(subst PosOrd_ex_def) |
432 |
apply(subst PosOrd_def) |
|
254 | 433 |
apply(case_tac p) |
434 |
apply(simp add: pflat_len_simps) |
|
435 |
apply(rule_tac x="Suc a#list" in exI) |
|
268 | 436 |
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps assms(2)) |
254 | 437 |
done |
438 |
||
261 | 439 |
lemma PosOrd_Stars_appendI: |
254 | 440 |
assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flat (Stars vs1) = flat (Stars vs2)" |
441 |
shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)" |
|
442 |
using assms |
|
443 |
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
|
444 |
apply(simp) |
261 | 445 |
apply(simp add: PosOrd_StarsI2) |
254 | 446 |
done |
447 |
||
261 | 448 |
lemma PosOrd_StarsE2: |
254 | 449 |
assumes "Stars (v # vs1) :\<sqsubset>val Stars (v # vs2)" |
450 |
shows "Stars vs1 :\<sqsubset>val Stars vs2" |
|
451 |
using assms |
|
261 | 452 |
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
|
453 |
apply(erule exE) |
254 | 454 |
apply(case_tac p) |
455 |
apply(simp) |
|
268 | 456 |
apply(simp add: PosOrd_def pflat_len_simps) |
261 | 457 |
apply(subst PosOrd_ex_def) |
254 | 458 |
apply(rule_tac x="[]" in exI) |
261 | 459 |
apply(simp add: PosOrd_def pflat_len_simps Pos_empty) |
254 | 460 |
apply(simp) |
461 |
apply(case_tac a) |
|
462 |
apply(clarify) |
|
264 | 463 |
apply(auto simp add: pflat_len_simps PosOrd_def pflat_len_def split: if_splits)[1] |
254 | 464 |
apply(clarify) |
261 | 465 |
apply(simp add: PosOrd_ex_def) |
254 | 466 |
apply(rule_tac x="nat#list" in exI) |
268 | 467 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 468 |
apply(case_tac q) |
268 | 469 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 470 |
apply(clarify) |
471 |
apply(drule_tac x="Suc a # lista" in bspec) |
|
472 |
apply(simp) |
|
268 | 473 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 474 |
apply(case_tac q) |
268 | 475 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 476 |
apply(clarify) |
477 |
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
|
478 |
apply(simp) |
268 | 479 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 480 |
done |
481 |
||
261 | 482 |
lemma PosOrd_Stars_appendE: |
254 | 483 |
assumes "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)" |
484 |
shows "Stars vs1 :\<sqsubset>val Stars vs2" |
|
485 |
using assms |
|
486 |
apply(induct vs) |
|
487 |
apply(simp) |
|
261 | 488 |
apply(simp add: PosOrd_StarsE2) |
254 | 489 |
done |
490 |
||
261 | 491 |
lemma PosOrd_Stars_append_eq: |
273 | 492 |
assumes "flats vs1 = flats vs2" |
254 | 493 |
shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2) \<longleftrightarrow> Stars vs1 :\<sqsubset>val Stars vs2" |
494 |
using assms |
|
495 |
apply(rule_tac iffI) |
|
261 | 496 |
apply(erule PosOrd_Stars_appendE) |
497 |
apply(rule PosOrd_Stars_appendI) |
|
254 | 498 |
apply(auto) |
273 | 499 |
done |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
500 |
|
261 | 501 |
lemma PosOrd_almost_trichotomous: |
273 | 502 |
shows "v1 :\<sqsubset>val v2 \<or> v2 :\<sqsubset>val v1 \<or> (length (flat v1) = length (flat v2))" |
261 | 503 |
apply(auto simp add: PosOrd_ex_def) |
504 |
apply(auto simp add: PosOrd_def) |
|
256 | 505 |
apply(rule_tac x="[]" in exI) |
506 |
apply(auto simp add: Pos_empty pflat_len_simps) |
|
507 |
apply(drule_tac x="[]" in spec) |
|
508 |
apply(auto simp add: Pos_empty pflat_len_simps) |
|
509 |
done |
|
510 |
||
511 |
||
267 | 512 |
|
261 | 513 |
section {* The Posix Value is smaller than any other Value *} |
514 |
||
262 | 515 |
|
261 | 516 |
lemma Posix_PosOrd: |
268 | 517 |
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
|
518 |
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
|
519 |
using assms |
261 | 520 |
proof (induct arbitrary: v2 rule: Posix.induct) |
521 |
case (Posix_ONE v) |
|
268 | 522 |
have "v \<in> LV ONE []" by fact |
262 | 523 |
then have "v = Void" |
268 | 524 |
by (simp add: LV_simps) |
261 | 525 |
then show "Void :\<sqsubseteq>val v" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
526 |
by (simp add: PosOrd_ex_eq_def) |
261 | 527 |
next |
528 |
case (Posix_CHAR c v) |
|
268 | 529 |
have "v \<in> LV (CHAR c) [c]" by fact |
262 | 530 |
then have "v = Char c" |
268 | 531 |
by (simp add: LV_simps) |
261 | 532 |
then show "Char c :\<sqsubseteq>val v" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
533 |
by (simp add: PosOrd_ex_eq_def) |
261 | 534 |
next |
535 |
case (Posix_ALT1 s r1 v r2 v2) |
|
536 |
have as1: "s \<in> r1 \<rightarrow> v" by fact |
|
268 | 537 |
have IH: "\<And>v2. v2 \<in> LV r1 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
538 |
have "v2 \<in> LV (ALT r1 r2) s" by fact |
|
262 | 539 |
then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
268 | 540 |
by(auto simp add: LV_def prefix_list_def) |
261 | 541 |
then consider |
262 | 542 |
(Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
543 |
| (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
|
268 | 544 |
by (auto elim: Prf.cases) |
261 | 545 |
then show "Left v :\<sqsubseteq>val v2" |
546 |
proof(cases) |
|
547 |
case (Left v3) |
|
268 | 548 |
have "v3 \<in> LV r1 s" using Left(2,3) |
549 |
by (auto simp add: LV_def prefix_list_def) |
|
261 | 550 |
with IH have "v :\<sqsubseteq>val v3" by simp |
551 |
moreover |
|
262 | 552 |
have "flat v3 = flat v" using as1 Left(3) |
553 |
by (simp add: Posix1(2)) |
|
261 | 554 |
ultimately have "Left v :\<sqsubseteq>val Left v3" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
555 |
by (simp add: PosOrd_ex_eq_def PosOrd_Left_eq) |
261 | 556 |
then show "Left v :\<sqsubseteq>val v2" unfolding Left . |
557 |
next |
|
558 |
case (Right v3) |
|
262 | 559 |
have "flat v3 = flat v" using as1 Right(3) |
560 |
by (simp add: Posix1(2)) |
|
268 | 561 |
then have "Left v :\<sqsubseteq>val Right v3" |
562 |
unfolding PosOrd_ex_eq_def |
|
563 |
by (simp add: PosOrd_Left_Right) |
|
261 | 564 |
then show "Left v :\<sqsubseteq>val v2" unfolding Right . |
565 |
qed |
|
566 |
next |
|
567 |
case (Posix_ALT2 s r2 v r1 v2) |
|
568 |
have as1: "s \<in> r2 \<rightarrow> v" by fact |
|
569 |
have as2: "s \<notin> L r1" by fact |
|
268 | 570 |
have IH: "\<And>v2. v2 \<in> LV r2 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
571 |
have "v2 \<in> LV (ALT r1 r2) s" by fact |
|
262 | 572 |
then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
268 | 573 |
by(auto simp add: LV_def prefix_list_def) |
261 | 574 |
then consider |
262 | 575 |
(Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
576 |
| (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
|
268 | 577 |
by (auto elim: Prf.cases) |
261 | 578 |
then show "Right v :\<sqsubseteq>val v2" |
579 |
proof (cases) |
|
580 |
case (Right v3) |
|
268 | 581 |
have "v3 \<in> LV r2 s" using Right(2,3) |
582 |
by (auto simp add: LV_def prefix_list_def) |
|
261 | 583 |
with IH have "v :\<sqsubseteq>val v3" by simp |
584 |
moreover |
|
262 | 585 |
have "flat v3 = flat v" using as1 Right(3) |
586 |
by (simp add: Posix1(2)) |
|
261 | 587 |
ultimately have "Right v :\<sqsubseteq>val Right v3" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
588 |
by (auto simp add: PosOrd_ex_eq_def PosOrd_RightI) |
261 | 589 |
then show "Right v :\<sqsubseteq>val v2" unfolding Right . |
590 |
next |
|
591 |
case (Left v3) |
|
268 | 592 |
have "v3 \<in> LV r1 s" using Left(2,3) as2 |
593 |
by (auto simp add: LV_def prefix_list_def) |
|
262 | 594 |
then have "flat v3 = flat v \<and> \<Turnstile> v3 : r1" using as1 Left(3) |
268 | 595 |
by (simp add: Posix1(2) LV_def) |
262 | 596 |
then have "False" using as1 as2 Left |
268 | 597 |
by (auto simp add: Posix1(2) L_flat_Prf1) |
262 | 598 |
then show "Right v :\<sqsubseteq>val v2" by simp |
261 | 599 |
qed |
600 |
next |
|
601 |
case (Posix_SEQ s1 r1 v1 s2 r2 v2 v3) |
|
264 | 602 |
have "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" by fact+ |
603 |
then have as1: "s1 = flat v1" "s2 = flat v2" by (simp_all add: Posix1(2)) |
|
268 | 604 |
have IH1: "\<And>v3. v3 \<in> LV r1 s1 \<Longrightarrow> v1 :\<sqsubseteq>val v3" by fact |
605 |
have IH2: "\<And>v3. v3 \<in> LV r2 s2 \<Longrightarrow> v2 :\<sqsubseteq>val v3" by fact |
|
261 | 606 |
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 | 607 |
have "v3 \<in> LV (SEQ r1 r2) (s1 @ s2)" by fact |
261 | 608 |
then obtain v3a v3b where eqs: |
609 |
"v3 = Seq v3a v3b" "\<Turnstile> v3a : r1" "\<Turnstile> v3b : r2" |
|
262 | 610 |
"flat v3a @ flat v3b = s1 @ s2" |
268 | 611 |
by (force simp add: prefix_list_def LV_def elim: Prf.cases) |
262 | 612 |
with cond have "flat v3a \<sqsubseteq>pre s1" unfolding prefix_list_def |
268 | 613 |
by (smt L_flat_Prf1 append_eq_append_conv2 append_self_conv) |
262 | 614 |
then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat v3b = s2)" using eqs |
615 |
by (simp add: sprefix_list_def append_eq_conv_conj) |
|
616 |
then have q2: "v1 :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat v3b = s2)" |
|
264 | 617 |
using PosOrd_spreI as1(1) eqs by blast |
268 | 618 |
then have "v1 :\<sqsubset>val v3a \<or> (v3a \<in> LV r1 s1 \<and> v3b \<in> LV r2 s2)" using eqs(2,3) |
619 |
by (auto simp add: LV_def) |
|
262 | 620 |
then have "v1 :\<sqsubset>val v3a \<or> (v1 :\<sqsubseteq>val v3a \<and> v2 :\<sqsubseteq>val v3b)" using IH1 IH2 by blast |
621 |
then have "Seq v1 v2 :\<sqsubseteq>val Seq v3a v3b" using eqs q2 as1 |
|
273 | 622 |
unfolding PosOrd_ex_eq_def by (auto simp add: PosOrd_SeqI1 PosOrd_Seq_eq) |
262 | 623 |
then show "Seq v1 v2 :\<sqsubseteq>val v3" unfolding eqs by blast |
261 | 624 |
next |
625 |
case (Posix_STAR1 s1 r v s2 vs v3) |
|
264 | 626 |
have "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" by fact+ |
627 |
then have as1: "s1 = flat v" "s2 = flat (Stars vs)" by (auto dest: Posix1(2)) |
|
268 | 628 |
have IH1: "\<And>v3. v3 \<in> LV r s1 \<Longrightarrow> v :\<sqsubseteq>val v3" by fact |
629 |
have IH2: "\<And>v3. v3 \<in> LV (STAR r) s2 \<Longrightarrow> Stars vs :\<sqsubseteq>val v3" by fact |
|
261 | 630 |
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 |
631 |
have cond2: "flat v \<noteq> []" by fact |
|
268 | 632 |
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
|
633 |
then consider |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
634 |
(NonEmpty) v3a vs3 where "v3 = Stars (v3a # vs3)" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
635 |
"\<Turnstile> v3a : r" "\<Turnstile> Stars vs3 : STAR r" |
262 | 636 |
"flat (Stars (v3a # vs3)) = s1 @ s2" |
261 | 637 |
| (Empty) "v3 = Stars []" |
268 | 638 |
unfolding LV_def |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
639 |
apply(auto) |
268 | 640 |
apply(erule Prf.cases) |
270 | 641 |
apply(auto) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
642 |
apply(case_tac vs) |
270 | 643 |
apply(auto intro: Prf.intros) |
644 |
done |
|
268 | 645 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" |
261 | 646 |
proof (cases) |
647 |
case (NonEmpty v3a vs3) |
|
262 | 648 |
have "flat (Stars (v3a # vs3)) = s1 @ s2" using NonEmpty(4) . |
649 |
with cond have "flat v3a \<sqsubseteq>pre s1" using NonEmpty(2,3) |
|
650 |
unfolding prefix_list_def |
|
268 | 651 |
by (smt L_flat_Prf1 append_Nil2 append_eq_append_conv2 flat.simps(7)) |
262 | 652 |
then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" using NonEmpty(4) |
653 |
by (simp add: sprefix_list_def append_eq_conv_conj) |
|
654 |
then have q2: "v :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" |
|
264 | 655 |
using PosOrd_spreI as1(1) NonEmpty(4) by blast |
268 | 656 |
then have "v :\<sqsubset>val v3a \<or> (v3a \<in> LV r s1 \<and> Stars vs3 \<in> LV (STAR r) s2)" |
657 |
using NonEmpty(2,3) by (auto simp add: LV_def) |
|
264 | 658 |
then have "v :\<sqsubset>val v3a \<or> (v :\<sqsubseteq>val v3a \<and> Stars vs :\<sqsubseteq>val Stars vs3)" using IH1 IH2 by blast |
659 |
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
|
660 |
unfolding PosOrd_ex_eq_def by auto |
262 | 661 |
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
|
662 |
unfolding PosOrd_ex_eq_def |
268 | 663 |
using PosOrd_StarsI PosOrd_StarsI2 by auto |
262 | 664 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" unfolding NonEmpty by blast |
261 | 665 |
next |
666 |
case Empty |
|
667 |
have "v3 = Stars []" by fact |
|
668 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
669 |
unfolding PosOrd_ex_eq_def using cond2 |
261 | 670 |
by (simp add: PosOrd_shorterI) |
671 |
qed |
|
672 |
next |
|
673 |
case (Posix_STAR2 r v2) |
|
268 | 674 |
have "v2 \<in> LV (STAR r) []" by fact |
262 | 675 |
then have "v2 = Stars []" |
268 | 676 |
unfolding LV_def by (auto elim: Prf.cases) |
261 | 677 |
then show "Stars [] :\<sqsubseteq>val v2" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
678 |
by (simp add: PosOrd_ex_eq_def) |
261 | 679 |
qed |
253 | 680 |
|
263 | 681 |
|
261 | 682 |
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
|
683 |
assumes "s \<in> r \<rightarrow> v1" |
268 | 684 |
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
|
685 |
using assms |
267 | 686 |
by (metis Posix_PosOrd less_irrefl PosOrd_def |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
687 |
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
|
688 |
|
261 | 689 |
lemma PosOrd_Posix: |
268 | 690 |
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
|
691 |
shows "s \<in> r \<rightarrow> v1" |
272 | 692 |
proof - |
693 |
have "s \<in> L r" using assms(1) unfolding LV_def |
|
694 |
using L_flat_Prf1 by blast |
|
695 |
then obtain vposix where vp: "s \<in> r \<rightarrow> vposix" |
|
696 |
using lexer_correct_Some by blast |
|
697 |
with assms(1) have "vposix :\<sqsubseteq>val v1" by (simp add: Posix_PosOrd) |
|
698 |
then have "vposix = v1 \<or> vposix :\<sqsubset>val v1" unfolding PosOrd_ex_eq2 by auto |
|
261 | 699 |
moreover |
272 | 700 |
{ assume "vposix :\<sqsubset>val v1" |
701 |
moreover |
|
702 |
have "vposix \<in> LV r s" using vp |
|
703 |
using Posix_LV by blast |
|
704 |
ultimately have "False" using assms(2) by blast |
|
705 |
} |
|
706 |
ultimately show "s \<in> r \<rightarrow> v1" using vp by blast |
|
261 | 707 |
qed |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
708 |
|
268 | 709 |
lemma Least_existence: |
710 |
assumes "LV r s \<noteq> {}" |
|
711 |
shows " \<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
|
712 |
proof - |
|
713 |
from assms |
|
714 |
obtain vposix where "s \<in> r \<rightarrow> vposix" |
|
715 |
unfolding LV_def |
|
716 |
using L_flat_Prf1 lexer_correct_Some by blast |
|
717 |
then have "\<forall>v \<in> LV r s. vposix :\<sqsubseteq>val v" |
|
718 |
by (simp add: Posix_PosOrd) |
|
719 |
then show "\<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
|
720 |
using Posix_LV \<open>s \<in> r \<rightarrow> vposix\<close> by blast |
|
721 |
qed |
|
722 |
||
723 |
lemma Least_existence1: |
|
724 |
assumes "LV r s \<noteq> {}" |
|
273 | 725 |
shows " \<exists>!vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
726 |
using Least_existence[OF assms] assms |
|
727 |
using PosOrdeq_antisym by blast |
|
728 |
||
729 |
||
730 |
||
731 |
||
732 |
||
733 |
lemma Least_existence1_pre: |
|
734 |
assumes "LV r s \<noteq> {}" |
|
268 | 735 |
shows " \<exists>!vmin \<in> LV r s. \<forall>v \<in> (LV r s \<union> {v'. flat v' \<sqsubset>spre s}). vmin :\<sqsubseteq>val v" |
736 |
using Least_existence[OF assms] assms |
|
737 |
apply - |
|
738 |
apply(erule bexE) |
|
739 |
apply(rule_tac a="vmin" in ex1I) |
|
740 |
apply(auto)[1] |
|
741 |
apply (metis PosOrd_Posix PosOrd_ex_eq2 PosOrd_spreI PosOrdeq_antisym Posix1(2)) |
|
742 |
apply(auto)[1] |
|
743 |
apply(simp add: PosOrdeq_antisym) |
|
744 |
done |
|
745 |
||
746 |
lemma |
|
747 |
shows "partial_order_on UNIV {(v1, v2). v1 :\<sqsubseteq>val v2}" |
|
748 |
apply(simp add: partial_order_on_def) |
|
749 |
apply(simp add: preorder_on_def refl_on_def) |
|
750 |
apply(simp add: PosOrdeq_refl) |
|
751 |
apply(auto) |
|
752 |
apply(rule transI) |
|
753 |
apply(auto intro: PosOrdeq_trans)[1] |
|
754 |
apply(rule antisymI) |
|
755 |
apply(simp add: PosOrdeq_antisym) |
|
756 |
done |
|
757 |
||
758 |
lemma |
|
759 |
"wf {(v1, v2). v1 :\<sqsubset>val v2 \<and> v1 \<in> LV r s \<and> v2 \<in> LV r s}" |
|
760 |
apply(rule finite_acyclic_wf) |
|
761 |
prefer 2 |
|
762 |
apply(simp add: acyclic_def) |
|
763 |
apply(induct_tac rule: trancl.induct) |
|
764 |
apply(auto)[1] |
|
765 |
oops |
|
766 |
||
767 |
||
249 | 768 |
unused_thms |
769 |
||
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
770 |
end |