author | Chengsong |
Wed, 23 Aug 2023 03:02:31 +0100 | |
changeset 668 | 3831621d7b14 |
parent 362 | e51c9a67a68d |
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 |
311 | 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 |
|
330 | 6 |
chapter \<open>An alternative definition for POSIX values\<close> |
311 | 7 |
|
330 | 8 |
section \<open>Positions in Values\<close> |
254 | 9 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
fun |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
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
|
12 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
"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
|
14 |
| "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
|
15 |
| "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
|
16 |
| "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
|
17 |
| "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
|
18 |
| "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
|
19 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
20 |
|
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
21 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
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
|
23 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
"Pos (Void) = {[]}" |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
| "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
|
26 |
| "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
|
27 |
| "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
|
28 |
| "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
|
29 |
| "Pos (Stars []) = {[]}" |
251 | 30 |
| "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
|
31 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
32 |
|
253 | 33 |
lemma Pos_stars: |
34 |
"Pos (Stars vs) = {[]} \<union> (\<Union>n < length vs. {n#ps | ps. ps \<in> Pos (vs ! n)})" |
|
35 |
apply(induct vs) |
|
267 | 36 |
apply(auto simp add: insert_ident less_Suc_eq_0_disj) |
37 |
done |
|
253 | 38 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
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
|
40 |
shows "[] \<in> Pos v" |
251 | 41 |
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
|
42 |
|
269 | 43 |
|
268 | 44 |
abbreviation |
45 |
"intlen vs \<equiv> int (length vs)" |
|
267 | 46 |
|
255 | 47 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
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
|
49 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
"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
|
51 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
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
|
58 |
and "pflat_len (Right v) (0#p) = -1" |
251 | 59 |
and "pflat_len (Stars (v#vs)) (Suc n#p) = pflat_len (Stars vs) (n#p)" |
60 |
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
|
61 |
and "pflat_len v [] = intlen (flat v)" |
251 | 62 |
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
|
63 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
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
|
65 |
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
|
66 |
shows "pflat_len (Stars vs) (n#p) = pflat_len (vs!n) p" |
267 | 67 |
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
|
68 |
apply(induct vs arbitrary: n p) |
251 | 69 |
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
|
70 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
72 |
lemma pflat_len_outside: |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
73 |
assumes "p \<notin> Pos v1" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
74 |
shows "pflat_len v1 p = -1 " |
267 | 75 |
using assms by (simp add: pflat_len_def) |
76 |
||
252 | 77 |
|
78 |
||
330 | 79 |
section \<open>Orderings\<close> |
252 | 80 |
|
81 |
||
257 | 82 |
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
|
83 |
where |
252 | 84 |
"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
|
85 |
|
257 | 86 |
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
|
87 |
where |
252 | 88 |
"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
|
89 |
|
257 | 90 |
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
|
91 |
where |
252 | 92 |
"[] \<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
|
93 |
| "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
|
94 |
| "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
|
95 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
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
|
100 |
using assms |
257 | 101 |
by(induct rule: lex_list.induct)(auto) |
102 |
||
251 | 103 |
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
|
104 |
fixes xs ys :: "nat list" |
251 | 105 |
shows "[] \<sqsubset>lex ys \<longleftrightarrow> ys \<noteq> []" |
106 |
and "xs \<sqsubset>lex [] \<longleftrightarrow> False" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
107 |
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
|
108 |
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
|
109 |
|
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
using assms |
264 | 115 |
by (induct arbitrary: ps3 rule: lex_list.induct) |
116 |
(auto elim: lex_list.cases) |
|
117 |
||
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
|
257 | 119 |
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
|
120 |
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
|
121 |
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
|
122 |
apply(induct p arbitrary: q) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
123 |
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
|
124 |
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
|
125 |
apply(auto) |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
|
254 | 128 |
|
129 |
||
130 |
||
330 | 131 |
section \<open>POSIX Ordering of Values According to Okui \& Suzuki\<close> |
254 | 132 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
|
261 | 134 |
definition PosOrd:: "val \<Rightarrow> nat list \<Rightarrow> val \<Rightarrow> bool" ("_ \<sqsubset>val _ _" [60, 60, 59] 60) |
135 |
where |
|
264 | 136 |
"v1 \<sqsubset>val p v2 \<equiv> pflat_len v1 p > pflat_len v2 p \<and> |
137 |
(\<forall>q \<in> Pos v1 \<union> Pos v2. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q)" |
|
138 |
||
273 | 139 |
lemma PosOrd_def2: |
269 | 140 |
shows "v1 \<sqsubset>val p v2 \<longleftrightarrow> |
141 |
pflat_len v1 p > pflat_len v2 p \<and> |
|
142 |
(\<forall>q \<in> Pos v1. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q) \<and> |
|
143 |
(\<forall>q \<in> Pos v2. q \<sqsubset>lex p \<longrightarrow> pflat_len v1 q = pflat_len v2 q)" |
|
144 |
unfolding PosOrd_def |
|
145 |
apply(auto) |
|
146 |
done |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
147 |
|
261 | 148 |
|
149 |
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
|
150 |
where |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
151 |
"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
|
152 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
153 |
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
|
154 |
where |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
"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
|
156 |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
157 |
|
268 | 158 |
lemma PosOrd_trans: |
159 |
assumes "v1 :\<sqsubset>val v2" "v2 :\<sqsubset>val v3" |
|
160 |
shows "v1 :\<sqsubset>val v3" |
|
161 |
proof - |
|
162 |
from assms obtain p p' |
|
163 |
where as: "v1 \<sqsubset>val p v2" "v2 \<sqsubset>val p' v3" unfolding PosOrd_ex_def by blast |
|
164 |
then have pos: "p \<in> Pos v1" "p' \<in> Pos v2" unfolding PosOrd_def pflat_len_def |
|
165 |
by (smt not_int_zless_negative)+ |
|
166 |
have "p = p' \<or> p \<sqsubset>lex p' \<or> p' \<sqsubset>lex p" |
|
167 |
by (rule lex_trichotomous) |
|
168 |
moreover |
|
169 |
{ assume "p = p'" |
|
170 |
with as have "v1 \<sqsubset>val p v3" unfolding PosOrd_def pflat_len_def |
|
171 |
by (smt Un_iff) |
|
172 |
then have " v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast |
|
173 |
} |
|
174 |
moreover |
|
175 |
{ assume "p \<sqsubset>lex p'" |
|
176 |
with as have "v1 \<sqsubset>val p v3" unfolding PosOrd_def pflat_len_def |
|
177 |
by (smt Un_iff lex_trans) |
|
178 |
then have " v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast |
|
179 |
} |
|
180 |
moreover |
|
181 |
{ assume "p' \<sqsubset>lex p" |
|
182 |
with as have "v1 \<sqsubset>val p' v3" unfolding PosOrd_def |
|
183 |
by (smt Un_iff lex_trans pflat_len_def) |
|
184 |
then have "v1 :\<sqsubset>val v3" unfolding PosOrd_ex_def by blast |
|
185 |
} |
|
186 |
ultimately show "v1 :\<sqsubset>val v3" by blast |
|
187 |
qed |
|
188 |
||
189 |
lemma PosOrd_irrefl: |
|
190 |
assumes "v :\<sqsubset>val v" |
|
191 |
shows "False" |
|
192 |
using assms unfolding PosOrd_ex_def PosOrd_def |
|
193 |
by auto |
|
194 |
||
195 |
lemma PosOrd_assym: |
|
196 |
assumes "v1 :\<sqsubset>val v2" |
|
197 |
shows "\<not>(v2 :\<sqsubset>val v1)" |
|
198 |
using assms |
|
199 |
using PosOrd_irrefl PosOrd_trans by blast |
|
200 |
||
307
ee1caac29bb2
updated to Isabelle 2018
Christian Urban <urbanc@in.tum.de>
parents:
292
diff
changeset
|
201 |
(* |
268 | 202 |
:\<sqsubseteq>val and :\<sqsubset>val are partial orders. |
307
ee1caac29bb2
updated to Isabelle 2018
Christian Urban <urbanc@in.tum.de>
parents:
292
diff
changeset
|
203 |
*) |
268 | 204 |
|
205 |
lemma PosOrd_ordering: |
|
206 |
shows "ordering (\<lambda>v1 v2. v1 :\<sqsubseteq>val v2) (\<lambda> v1 v2. v1 :\<sqsubset>val v2)" |
|
207 |
unfolding ordering_def PosOrd_ex_eq_def |
|
208 |
apply(auto) |
|
209 |
using PosOrd_irrefl apply blast |
|
210 |
using PosOrd_assym apply blast |
|
211 |
using PosOrd_trans by blast |
|
212 |
||
213 |
lemma PosOrd_order: |
|
214 |
shows "class.order (\<lambda>v1 v2. v1 :\<sqsubseteq>val v2) (\<lambda> v1 v2. v1 :\<sqsubset>val v2)" |
|
215 |
using PosOrd_ordering |
|
216 |
apply(simp add: class.order_def class.preorder_def class.order_axioms_def) |
|
217 |
unfolding ordering_def |
|
218 |
by blast |
|
219 |
||
220 |
||
221 |
lemma PosOrd_ex_eq2: |
|
222 |
shows "v1 :\<sqsubset>val v2 \<longleftrightarrow> (v1 :\<sqsubseteq>val v2 \<and> v1 \<noteq> v2)" |
|
223 |
using PosOrd_ordering |
|
224 |
unfolding ordering_def |
|
225 |
by auto |
|
226 |
||
227 |
lemma PosOrdeq_trans: |
|
228 |
assumes "v1 :\<sqsubseteq>val v2" "v2 :\<sqsubseteq>val v3" |
|
229 |
shows "v1 :\<sqsubseteq>val v3" |
|
230 |
using assms PosOrd_ordering |
|
231 |
unfolding ordering_def |
|
232 |
by blast |
|
233 |
||
234 |
lemma PosOrdeq_antisym: |
|
235 |
assumes "v1 :\<sqsubseteq>val v2" "v2 :\<sqsubseteq>val v1" |
|
236 |
shows "v1 = v2" |
|
237 |
using assms PosOrd_ordering |
|
238 |
unfolding ordering_def |
|
239 |
by blast |
|
240 |
||
241 |
lemma PosOrdeq_refl: |
|
242 |
shows "v :\<sqsubseteq>val v" |
|
243 |
unfolding PosOrd_ex_eq_def |
|
244 |
by auto |
|
245 |
||
246 |
||
261 | 247 |
lemma PosOrd_shorterE: |
255 | 248 |
assumes "v1 :\<sqsubset>val v2" |
249 |
shows "length (flat v2) \<le> length (flat v1)" |
|
267 | 250 |
using assms unfolding PosOrd_ex_def PosOrd_def |
273 | 251 |
apply(auto) |
252 |
apply(case_tac p) |
|
253 |
apply(simp add: pflat_len_simps) |
|
254 |
apply(drule_tac x="[]" in bspec) |
|
255 |
apply(simp add: Pos_empty) |
|
256 |
apply(simp add: pflat_len_simps) |
|
257 |
done |
|
255 | 258 |
|
261 | 259 |
lemma PosOrd_shorterI: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
260 |
assumes "length (flat v2) < length (flat v1)" |
268 | 261 |
shows "v1 :\<sqsubset>val v2" |
262 |
unfolding PosOrd_ex_def PosOrd_def pflat_len_def |
|
263 |
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
|
264 |
|
261 | 265 |
lemma PosOrd_spreI: |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
266 |
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
|
267 |
shows "v :\<sqsubset>val v'" |
251 | 268 |
using assms |
261 | 269 |
apply(rule_tac PosOrd_shorterI) |
268 | 270 |
unfolding prefix_list_def sprefix_list_def |
271 |
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
|
272 |
|
269 | 273 |
lemma pflat_len_inside: |
274 |
assumes "pflat_len v2 p < pflat_len v1 p" |
|
275 |
shows "p \<in> Pos v1" |
|
276 |
using assms |
|
277 |
unfolding pflat_len_def |
|
278 |
by (auto split: if_splits) |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
279 |
|
273 | 280 |
|
261 | 281 |
lemma PosOrd_Left_Right: |
282 |
assumes "flat v1 = flat v2" |
|
283 |
shows "Left v1 :\<sqsubset>val Right v2" |
|
284 |
unfolding PosOrd_ex_def |
|
285 |
apply(rule_tac x="[0]" in exI) |
|
269 | 286 |
apply(auto simp add: PosOrd_def pflat_len_simps assms) |
261 | 287 |
done |
256 | 288 |
|
269 | 289 |
lemma PosOrd_LeftE: |
290 |
assumes "Left v1 :\<sqsubset>val Left v2" "flat v1 = flat v2" |
|
291 |
shows "v1 :\<sqsubset>val v2" |
|
292 |
using assms |
|
273 | 293 |
unfolding PosOrd_ex_def PosOrd_def2 |
269 | 294 |
apply(auto simp add: pflat_len_simps) |
295 |
apply(frule pflat_len_inside) |
|
296 |
apply(auto simp add: pflat_len_simps) |
|
297 |
by (metis lex_simps(3) pflat_len_simps(3)) |
|
298 |
||
299 |
lemma PosOrd_LeftI: |
|
300 |
assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2" |
|
301 |
shows "Left v1 :\<sqsubset>val Left v2" |
|
302 |
using assms |
|
273 | 303 |
unfolding PosOrd_ex_def PosOrd_def2 |
269 | 304 |
apply(auto simp add: pflat_len_simps) |
305 |
by (metis less_numeral_extra(3) lex_simps(3) pflat_len_simps(3)) |
|
306 |
||
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
307 |
lemma PosOrd_Left_eq: |
269 | 308 |
assumes "flat v1 = flat v2" |
309 |
shows "Left v1 :\<sqsubset>val Left v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" |
|
310 |
using assms PosOrd_LeftE PosOrd_LeftI |
|
311 |
by blast |
|
312 |
||
313 |
||
314 |
lemma PosOrd_RightE: |
|
315 |
assumes "Right v1 :\<sqsubset>val Right v2" "flat v1 = flat v2" |
|
316 |
shows "v1 :\<sqsubset>val v2" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
317 |
using assms |
273 | 318 |
unfolding PosOrd_ex_def PosOrd_def2 |
269 | 319 |
apply(auto simp add: pflat_len_simps) |
320 |
apply(frule pflat_len_inside) |
|
321 |
apply(auto simp add: pflat_len_simps) |
|
322 |
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
|
323 |
|
261 | 324 |
lemma PosOrd_RightI: |
269 | 325 |
assumes "v1 :\<sqsubset>val v2" "flat v1 = flat v2" |
326 |
shows "Right v1 :\<sqsubset>val Right v2" |
|
252 | 327 |
using assms |
273 | 328 |
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
|
329 |
apply(auto simp add: pflat_len_simps) |
269 | 330 |
by (metis lex_simps(3) nat_neq_iff pflat_len_simps(5)) |
331 |
||
332 |
||
333 |
lemma PosOrd_Right_eq: |
|
334 |
assumes "flat v1 = flat v2" |
|
335 |
shows "Right v1 :\<sqsubset>val Right v2 \<longleftrightarrow> v1 :\<sqsubset>val v2" |
|
336 |
using assms PosOrd_RightE PosOrd_RightI |
|
337 |
by blast |
|
252 | 338 |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
339 |
|
261 | 340 |
lemma PosOrd_SeqI1: |
273 | 341 |
assumes "v1 :\<sqsubset>val w1" "flat (Seq v1 v2) = flat (Seq w1 w2)" |
342 |
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
|
343 |
using assms(1) |
261 | 344 |
apply(subst (asm) PosOrd_ex_def) |
345 |
apply(subst (asm) PosOrd_def) |
|
252 | 346 |
apply(clarify) |
261 | 347 |
apply(subst PosOrd_ex_def) |
252 | 348 |
apply(rule_tac x="0#p" in exI) |
261 | 349 |
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
|
350 |
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
|
351 |
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
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
apply(simp add: pflat_len_simps) |
273 | 357 |
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
|
358 |
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
|
359 |
apply(simp) |
273 | 360 |
apply(metis length_append of_nat_add) |
361 |
done |
|
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
362 |
|
261 | 363 |
lemma PosOrd_SeqI2: |
273 | 364 |
assumes "v2 :\<sqsubset>val w2" "flat v2 = flat w2" |
365 |
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
|
366 |
using assms(1) |
261 | 367 |
apply(subst (asm) PosOrd_ex_def) |
368 |
apply(subst (asm) PosOrd_def) |
|
252 | 369 |
apply(clarify) |
261 | 370 |
apply(subst PosOrd_ex_def) |
252 | 371 |
apply(rule_tac x="Suc 0#p" in exI) |
261 | 372 |
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
|
373 |
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
|
374 |
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
|
375 |
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
|
376 |
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
|
377 |
apply(simp only: Pos.simps) |
252 | 378 |
apply(auto)[1] |
379 |
apply(simp add: pflat_len_simps) |
|
380 |
using assms(2) |
|
381 |
apply(simp) |
|
382 |
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
|
383 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
384 |
|
273 | 385 |
lemma PosOrd_Seq_eq: |
386 |
assumes "flat v2 = flat w2" |
|
387 |
shows "(Seq v v2) :\<sqsubset>val (Seq v w2) \<longleftrightarrow> v2 :\<sqsubset>val w2" |
|
388 |
using assms |
|
389 |
apply(auto) |
|
390 |
prefer 2 |
|
391 |
apply(simp add: PosOrd_SeqI2) |
|
261 | 392 |
apply(simp add: PosOrd_ex_def) |
273 | 393 |
apply(auto) |
254 | 394 |
apply(case_tac p) |
273 | 395 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 396 |
apply(case_tac a) |
273 | 397 |
apply(simp add: PosOrd_def pflat_len_simps) |
398 |
apply(clarify) |
|
399 |
apply(case_tac nat) |
|
400 |
prefer 2 |
|
401 |
apply(simp add: PosOrd_def pflat_len_simps pflat_len_outside) |
|
254 | 402 |
apply(rule_tac x="list" in exI) |
273 | 403 |
apply(auto simp add: PosOrd_def2 pflat_len_simps) |
404 |
apply(smt Collect_disj_eq lex_list.intros(2) mem_Collect_eq pflat_len_simps(2)) |
|
405 |
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
|
406 |
done |
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
407 |
|
273 | 408 |
|
409 |
||
261 | 410 |
lemma PosOrd_StarsI: |
268 | 411 |
assumes "v1 :\<sqsubset>val v2" "flats (v1#vs1) = flats (v2#vs2)" |
412 |
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
|
413 |
using assms(1) |
261 | 414 |
apply(subst (asm) PosOrd_ex_def) |
415 |
apply(subst (asm) PosOrd_def) |
|
254 | 416 |
apply(clarify) |
261 | 417 |
apply(subst PosOrd_ex_def) |
418 |
apply(subst PosOrd_def) |
|
254 | 419 |
apply(rule_tac x="0#p" in exI) |
420 |
apply(simp add: pflat_len_Stars_simps pflat_len_simps) |
|
421 |
using assms(2) |
|
268 | 422 |
apply(simp add: pflat_len_simps) |
254 | 423 |
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps) |
268 | 424 |
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
|
425 |
|
261 | 426 |
lemma PosOrd_StarsI2: |
268 | 427 |
assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flats vs1 = flats vs2" |
428 |
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
|
429 |
using assms(1) |
261 | 430 |
apply(subst (asm) PosOrd_ex_def) |
431 |
apply(subst (asm) PosOrd_def) |
|
254 | 432 |
apply(clarify) |
261 | 433 |
apply(subst PosOrd_ex_def) |
434 |
apply(subst PosOrd_def) |
|
254 | 435 |
apply(case_tac p) |
436 |
apply(simp add: pflat_len_simps) |
|
437 |
apply(rule_tac x="Suc a#list" in exI) |
|
268 | 438 |
apply(auto simp add: pflat_len_Stars_simps pflat_len_simps assms(2)) |
254 | 439 |
done |
440 |
||
261 | 441 |
lemma PosOrd_Stars_appendI: |
254 | 442 |
assumes "Stars vs1 :\<sqsubset>val Stars vs2" "flat (Stars vs1) = flat (Stars vs2)" |
443 |
shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)" |
|
444 |
using assms |
|
445 |
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
|
446 |
apply(simp) |
261 | 447 |
apply(simp add: PosOrd_StarsI2) |
254 | 448 |
done |
449 |
||
261 | 450 |
lemma PosOrd_StarsE2: |
254 | 451 |
assumes "Stars (v # vs1) :\<sqsubset>val Stars (v # vs2)" |
452 |
shows "Stars vs1 :\<sqsubset>val Stars vs2" |
|
453 |
using assms |
|
261 | 454 |
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
|
455 |
apply(erule exE) |
254 | 456 |
apply(case_tac p) |
457 |
apply(simp) |
|
268 | 458 |
apply(simp add: PosOrd_def pflat_len_simps) |
261 | 459 |
apply(subst PosOrd_ex_def) |
254 | 460 |
apply(rule_tac x="[]" in exI) |
261 | 461 |
apply(simp add: PosOrd_def pflat_len_simps Pos_empty) |
254 | 462 |
apply(simp) |
463 |
apply(case_tac a) |
|
464 |
apply(clarify) |
|
264 | 465 |
apply(auto simp add: pflat_len_simps PosOrd_def pflat_len_def split: if_splits)[1] |
254 | 466 |
apply(clarify) |
261 | 467 |
apply(simp add: PosOrd_ex_def) |
254 | 468 |
apply(rule_tac x="nat#list" in exI) |
268 | 469 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 470 |
apply(case_tac q) |
268 | 471 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 472 |
apply(clarify) |
473 |
apply(drule_tac x="Suc a # lista" in bspec) |
|
474 |
apply(simp) |
|
268 | 475 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 476 |
apply(case_tac q) |
268 | 477 |
apply(simp add: PosOrd_def pflat_len_simps) |
254 | 478 |
apply(clarify) |
479 |
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
|
480 |
apply(simp) |
268 | 481 |
apply(auto simp add: PosOrd_def pflat_len_simps)[1] |
254 | 482 |
done |
483 |
||
261 | 484 |
lemma PosOrd_Stars_appendE: |
254 | 485 |
assumes "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2)" |
486 |
shows "Stars vs1 :\<sqsubset>val Stars vs2" |
|
487 |
using assms |
|
488 |
apply(induct vs) |
|
489 |
apply(simp) |
|
261 | 490 |
apply(simp add: PosOrd_StarsE2) |
254 | 491 |
done |
492 |
||
261 | 493 |
lemma PosOrd_Stars_append_eq: |
273 | 494 |
assumes "flats vs1 = flats vs2" |
254 | 495 |
shows "Stars (vs @ vs1) :\<sqsubset>val Stars (vs @ vs2) \<longleftrightarrow> Stars vs1 :\<sqsubset>val Stars vs2" |
496 |
using assms |
|
497 |
apply(rule_tac iffI) |
|
261 | 498 |
apply(erule PosOrd_Stars_appendE) |
499 |
apply(rule PosOrd_Stars_appendI) |
|
254 | 500 |
apply(auto) |
273 | 501 |
done |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
502 |
|
261 | 503 |
lemma PosOrd_almost_trichotomous: |
273 | 504 |
shows "v1 :\<sqsubset>val v2 \<or> v2 :\<sqsubset>val v1 \<or> (length (flat v1) = length (flat v2))" |
261 | 505 |
apply(auto simp add: PosOrd_ex_def) |
506 |
apply(auto simp add: PosOrd_def) |
|
256 | 507 |
apply(rule_tac x="[]" in exI) |
508 |
apply(auto simp add: Pos_empty pflat_len_simps) |
|
509 |
apply(drule_tac x="[]" in spec) |
|
510 |
apply(auto simp add: Pos_empty pflat_len_simps) |
|
511 |
done |
|
512 |
||
513 |
||
267 | 514 |
|
330 | 515 |
section \<open>The Posix Value is smaller than any other Value\<close> |
261 | 516 |
|
262 | 517 |
|
261 | 518 |
lemma Posix_PosOrd: |
268 | 519 |
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
|
520 |
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
|
521 |
using assms |
261 | 522 |
proof (induct arbitrary: v2 rule: Posix.induct) |
523 |
case (Posix_ONE v) |
|
268 | 524 |
have "v \<in> LV ONE []" by fact |
262 | 525 |
then have "v = Void" |
268 | 526 |
by (simp add: LV_simps) |
261 | 527 |
then show "Void :\<sqsubseteq>val v" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
528 |
by (simp add: PosOrd_ex_eq_def) |
261 | 529 |
next |
362 | 530 |
case (Posix_CH c v) |
531 |
have "v \<in> LV (CH c) [c]" by fact |
|
262 | 532 |
then have "v = Char c" |
268 | 533 |
by (simp add: LV_simps) |
261 | 534 |
then show "Char c :\<sqsubseteq>val v" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
535 |
by (simp add: PosOrd_ex_eq_def) |
261 | 536 |
next |
537 |
case (Posix_ALT1 s r1 v r2 v2) |
|
538 |
have as1: "s \<in> r1 \<rightarrow> v" by fact |
|
268 | 539 |
have IH: "\<And>v2. v2 \<in> LV r1 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
540 |
have "v2 \<in> LV (ALT r1 r2) s" by fact |
|
262 | 541 |
then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
268 | 542 |
by(auto simp add: LV_def prefix_list_def) |
261 | 543 |
then consider |
262 | 544 |
(Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
545 |
| (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
|
268 | 546 |
by (auto elim: Prf.cases) |
261 | 547 |
then show "Left v :\<sqsubseteq>val v2" |
548 |
proof(cases) |
|
549 |
case (Left v3) |
|
268 | 550 |
have "v3 \<in> LV r1 s" using Left(2,3) |
551 |
by (auto simp add: LV_def prefix_list_def) |
|
261 | 552 |
with IH have "v :\<sqsubseteq>val v3" by simp |
553 |
moreover |
|
262 | 554 |
have "flat v3 = flat v" using as1 Left(3) |
555 |
by (simp add: Posix1(2)) |
|
261 | 556 |
ultimately have "Left v :\<sqsubseteq>val Left v3" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
557 |
by (simp add: PosOrd_ex_eq_def PosOrd_Left_eq) |
261 | 558 |
then show "Left v :\<sqsubseteq>val v2" unfolding Left . |
559 |
next |
|
560 |
case (Right v3) |
|
262 | 561 |
have "flat v3 = flat v" using as1 Right(3) |
562 |
by (simp add: Posix1(2)) |
|
268 | 563 |
then have "Left v :\<sqsubseteq>val Right v3" |
564 |
unfolding PosOrd_ex_eq_def |
|
565 |
by (simp add: PosOrd_Left_Right) |
|
261 | 566 |
then show "Left v :\<sqsubseteq>val v2" unfolding Right . |
567 |
qed |
|
568 |
next |
|
569 |
case (Posix_ALT2 s r2 v r1 v2) |
|
570 |
have as1: "s \<in> r2 \<rightarrow> v" by fact |
|
571 |
have as2: "s \<notin> L r1" by fact |
|
268 | 572 |
have IH: "\<And>v2. v2 \<in> LV r2 s \<Longrightarrow> v :\<sqsubseteq>val v2" by fact |
573 |
have "v2 \<in> LV (ALT r1 r2) s" by fact |
|
262 | 574 |
then have "\<Turnstile> v2 : ALT r1 r2" "flat v2 = s" |
268 | 575 |
by(auto simp add: LV_def prefix_list_def) |
261 | 576 |
then consider |
262 | 577 |
(Left) v3 where "v2 = Left v3" "\<Turnstile> v3 : r1" "flat v3 = s" |
578 |
| (Right) v3 where "v2 = Right v3" "\<Turnstile> v3 : r2" "flat v3 = s" |
|
268 | 579 |
by (auto elim: Prf.cases) |
261 | 580 |
then show "Right v :\<sqsubseteq>val v2" |
581 |
proof (cases) |
|
582 |
case (Right v3) |
|
268 | 583 |
have "v3 \<in> LV r2 s" using Right(2,3) |
584 |
by (auto simp add: LV_def prefix_list_def) |
|
261 | 585 |
with IH have "v :\<sqsubseteq>val v3" by simp |
586 |
moreover |
|
262 | 587 |
have "flat v3 = flat v" using as1 Right(3) |
588 |
by (simp add: Posix1(2)) |
|
261 | 589 |
ultimately have "Right v :\<sqsubseteq>val Right v3" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
590 |
by (auto simp add: PosOrd_ex_eq_def PosOrd_RightI) |
261 | 591 |
then show "Right v :\<sqsubseteq>val v2" unfolding Right . |
592 |
next |
|
593 |
case (Left v3) |
|
268 | 594 |
have "v3 \<in> LV r1 s" using Left(2,3) as2 |
595 |
by (auto simp add: LV_def prefix_list_def) |
|
262 | 596 |
then have "flat v3 = flat v \<and> \<Turnstile> v3 : r1" using as1 Left(3) |
268 | 597 |
by (simp add: Posix1(2) LV_def) |
262 | 598 |
then have "False" using as1 as2 Left |
268 | 599 |
by (auto simp add: Posix1(2) L_flat_Prf1) |
262 | 600 |
then show "Right v :\<sqsubseteq>val v2" by simp |
261 | 601 |
qed |
602 |
next |
|
603 |
case (Posix_SEQ s1 r1 v1 s2 r2 v2 v3) |
|
264 | 604 |
have "s1 \<in> r1 \<rightarrow> v1" "s2 \<in> r2 \<rightarrow> v2" by fact+ |
605 |
then have as1: "s1 = flat v1" "s2 = flat v2" by (simp_all add: Posix1(2)) |
|
268 | 606 |
have IH1: "\<And>v3. v3 \<in> LV r1 s1 \<Longrightarrow> v1 :\<sqsubseteq>val v3" by fact |
607 |
have IH2: "\<And>v3. v3 \<in> LV r2 s2 \<Longrightarrow> v2 :\<sqsubseteq>val v3" by fact |
|
261 | 608 |
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 | 609 |
have "v3 \<in> LV (SEQ r1 r2) (s1 @ s2)" by fact |
261 | 610 |
then obtain v3a v3b where eqs: |
611 |
"v3 = Seq v3a v3b" "\<Turnstile> v3a : r1" "\<Turnstile> v3b : r2" |
|
262 | 612 |
"flat v3a @ flat v3b = s1 @ s2" |
268 | 613 |
by (force simp add: prefix_list_def LV_def elim: Prf.cases) |
262 | 614 |
with cond have "flat v3a \<sqsubseteq>pre s1" unfolding prefix_list_def |
268 | 615 |
by (smt L_flat_Prf1 append_eq_append_conv2 append_self_conv) |
262 | 616 |
then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat v3b = s2)" using eqs |
617 |
by (simp add: sprefix_list_def append_eq_conv_conj) |
|
618 |
then have q2: "v1 :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat v3b = s2)" |
|
264 | 619 |
using PosOrd_spreI as1(1) eqs by blast |
268 | 620 |
then have "v1 :\<sqsubset>val v3a \<or> (v3a \<in> LV r1 s1 \<and> v3b \<in> LV r2 s2)" using eqs(2,3) |
621 |
by (auto simp add: LV_def) |
|
262 | 622 |
then have "v1 :\<sqsubset>val v3a \<or> (v1 :\<sqsubseteq>val v3a \<and> v2 :\<sqsubseteq>val v3b)" using IH1 IH2 by blast |
623 |
then have "Seq v1 v2 :\<sqsubseteq>val Seq v3a v3b" using eqs q2 as1 |
|
273 | 624 |
unfolding PosOrd_ex_eq_def by (auto simp add: PosOrd_SeqI1 PosOrd_Seq_eq) |
262 | 625 |
then show "Seq v1 v2 :\<sqsubseteq>val v3" unfolding eqs by blast |
261 | 626 |
next |
627 |
case (Posix_STAR1 s1 r v s2 vs v3) |
|
264 | 628 |
have "s1 \<in> r \<rightarrow> v" "s2 \<in> STAR r \<rightarrow> Stars vs" by fact+ |
629 |
then have as1: "s1 = flat v" "s2 = flat (Stars vs)" by (auto dest: Posix1(2)) |
|
268 | 630 |
have IH1: "\<And>v3. v3 \<in> LV r s1 \<Longrightarrow> v :\<sqsubseteq>val v3" by fact |
631 |
have IH2: "\<And>v3. v3 \<in> LV (STAR r) s2 \<Longrightarrow> Stars vs :\<sqsubseteq>val v3" by fact |
|
261 | 632 |
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 |
633 |
have cond2: "flat v \<noteq> []" by fact |
|
268 | 634 |
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
|
635 |
then consider |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
636 |
(NonEmpty) v3a vs3 where "v3 = Stars (v3a # vs3)" |
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
637 |
"\<Turnstile> v3a : r" "\<Turnstile> Stars vs3 : STAR r" |
262 | 638 |
"flat (Stars (v3a # vs3)) = s1 @ s2" |
261 | 639 |
| (Empty) "v3 = Stars []" |
268 | 640 |
unfolding LV_def |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
641 |
apply(auto) |
268 | 642 |
apply(erule Prf.cases) |
270 | 643 |
apply(auto) |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
644 |
apply(case_tac vs) |
270 | 645 |
apply(auto intro: Prf.intros) |
646 |
done |
|
268 | 647 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" |
261 | 648 |
proof (cases) |
649 |
case (NonEmpty v3a vs3) |
|
262 | 650 |
have "flat (Stars (v3a # vs3)) = s1 @ s2" using NonEmpty(4) . |
651 |
with cond have "flat v3a \<sqsubseteq>pre s1" using NonEmpty(2,3) |
|
652 |
unfolding prefix_list_def |
|
268 | 653 |
by (smt L_flat_Prf1 append_Nil2 append_eq_append_conv2 flat.simps(7)) |
262 | 654 |
then have "flat v3a \<sqsubset>spre s1 \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" using NonEmpty(4) |
655 |
by (simp add: sprefix_list_def append_eq_conv_conj) |
|
656 |
then have q2: "v :\<sqsubset>val v3a \<or> (flat v3a = s1 \<and> flat (Stars vs3) = s2)" |
|
264 | 657 |
using PosOrd_spreI as1(1) NonEmpty(4) by blast |
268 | 658 |
then have "v :\<sqsubset>val v3a \<or> (v3a \<in> LV r s1 \<and> Stars vs3 \<in> LV (STAR r) s2)" |
659 |
using NonEmpty(2,3) by (auto simp add: LV_def) |
|
264 | 660 |
then have "v :\<sqsubset>val v3a \<or> (v :\<sqsubseteq>val v3a \<and> Stars vs :\<sqsubseteq>val Stars vs3)" using IH1 IH2 by blast |
661 |
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
|
662 |
unfolding PosOrd_ex_eq_def by auto |
262 | 663 |
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
|
664 |
unfolding PosOrd_ex_eq_def |
268 | 665 |
using PosOrd_StarsI PosOrd_StarsI2 by auto |
262 | 666 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" unfolding NonEmpty by blast |
261 | 667 |
next |
668 |
case Empty |
|
669 |
have "v3 = Stars []" by fact |
|
670 |
then show "Stars (v # vs) :\<sqsubseteq>val v3" |
|
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
671 |
unfolding PosOrd_ex_eq_def using cond2 |
261 | 672 |
by (simp add: PosOrd_shorterI) |
673 |
qed |
|
674 |
next |
|
675 |
case (Posix_STAR2 r v2) |
|
268 | 676 |
have "v2 \<in> LV (STAR r) []" by fact |
262 | 677 |
then have "v2 = Stars []" |
268 | 678 |
unfolding LV_def by (auto elim: Prf.cases) |
261 | 679 |
then show "Stars [] :\<sqsubseteq>val v2" |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
680 |
by (simp add: PosOrd_ex_eq_def) |
261 | 681 |
qed |
253 | 682 |
|
263 | 683 |
|
261 | 684 |
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
|
685 |
assumes "s \<in> r \<rightarrow> v1" |
268 | 686 |
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
|
687 |
using assms |
267 | 688 |
by (metis Posix_PosOrd less_irrefl PosOrd_def |
265
d36be1e356c0
changed definitions of PRF
Christian Urban <urbanc@in.tum.de>
parents:
264
diff
changeset
|
689 |
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
|
690 |
|
261 | 691 |
lemma PosOrd_Posix: |
268 | 692 |
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
|
693 |
shows "s \<in> r \<rightarrow> v1" |
272 | 694 |
proof - |
695 |
have "s \<in> L r" using assms(1) unfolding LV_def |
|
696 |
using L_flat_Prf1 by blast |
|
697 |
then obtain vposix where vp: "s \<in> r \<rightarrow> vposix" |
|
698 |
using lexer_correct_Some by blast |
|
699 |
with assms(1) have "vposix :\<sqsubseteq>val v1" by (simp add: Posix_PosOrd) |
|
700 |
then have "vposix = v1 \<or> vposix :\<sqsubset>val v1" unfolding PosOrd_ex_eq2 by auto |
|
261 | 701 |
moreover |
272 | 702 |
{ assume "vposix :\<sqsubset>val v1" |
703 |
moreover |
|
704 |
have "vposix \<in> LV r s" using vp |
|
705 |
using Posix_LV by blast |
|
706 |
ultimately have "False" using assms(2) by blast |
|
707 |
} |
|
708 |
ultimately show "s \<in> r \<rightarrow> v1" using vp by blast |
|
261 | 709 |
qed |
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
710 |
|
268 | 711 |
lemma Least_existence: |
712 |
assumes "LV r s \<noteq> {}" |
|
713 |
shows " \<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
|
714 |
proof - |
|
715 |
from assms |
|
716 |
obtain vposix where "s \<in> r \<rightarrow> vposix" |
|
717 |
unfolding LV_def |
|
718 |
using L_flat_Prf1 lexer_correct_Some by blast |
|
719 |
then have "\<forall>v \<in> LV r s. vposix :\<sqsubseteq>val v" |
|
720 |
by (simp add: Posix_PosOrd) |
|
721 |
then show "\<exists>vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
|
722 |
using Posix_LV \<open>s \<in> r \<rightarrow> vposix\<close> by blast |
|
723 |
qed |
|
724 |
||
725 |
lemma Least_existence1: |
|
726 |
assumes "LV r s \<noteq> {}" |
|
273 | 727 |
shows " \<exists>!vmin \<in> LV r s. \<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v" |
728 |
using Least_existence[OF assms] assms |
|
729 |
using PosOrdeq_antisym by blast |
|
730 |
||
292 | 731 |
lemma Least_existence2: |
732 |
assumes "LV r s \<noteq> {}" |
|
733 |
shows " \<exists>!vmin \<in> LV r s. lexer r s = Some vmin \<and> (\<forall>v \<in> LV r s. vmin :\<sqsubseteq>val v)" |
|
734 |
using Least_existence[OF assms] assms |
|
735 |
using PosOrdeq_antisym |
|
736 |
using PosOrd_Posix PosOrd_ex_eq2 lexer_correctness(1) by auto |
|
273 | 737 |
|
738 |
||
739 |
lemma Least_existence1_pre: |
|
740 |
assumes "LV r s \<noteq> {}" |
|
268 | 741 |
shows " \<exists>!vmin \<in> LV r s. \<forall>v \<in> (LV r s \<union> {v'. flat v' \<sqsubset>spre s}). vmin :\<sqsubseteq>val v" |
742 |
using Least_existence[OF assms] assms |
|
743 |
apply - |
|
744 |
apply(erule bexE) |
|
745 |
apply(rule_tac a="vmin" in ex1I) |
|
746 |
apply(auto)[1] |
|
747 |
apply (metis PosOrd_Posix PosOrd_ex_eq2 PosOrd_spreI PosOrdeq_antisym Posix1(2)) |
|
748 |
apply(auto)[1] |
|
749 |
apply(simp add: PosOrdeq_antisym) |
|
750 |
done |
|
751 |
||
752 |
lemma |
|
753 |
shows "partial_order_on UNIV {(v1, v2). v1 :\<sqsubseteq>val v2}" |
|
754 |
apply(simp add: partial_order_on_def) |
|
755 |
apply(simp add: preorder_on_def refl_on_def) |
|
756 |
apply(simp add: PosOrdeq_refl) |
|
757 |
apply(auto) |
|
758 |
apply(rule transI) |
|
759 |
apply(auto intro: PosOrdeq_trans)[1] |
|
760 |
apply(rule antisymI) |
|
761 |
apply(simp add: PosOrdeq_antisym) |
|
762 |
done |
|
763 |
||
764 |
lemma |
|
765 |
"wf {(v1, v2). v1 :\<sqsubset>val v2 \<and> v1 \<in> LV r s \<and> v2 \<in> LV r s}" |
|
766 |
apply(rule finite_acyclic_wf) |
|
767 |
prefer 2 |
|
768 |
apply(simp add: acyclic_def) |
|
769 |
apply(induct_tac rule: trancl.induct) |
|
770 |
apply(auto)[1] |
|
771 |
oops |
|
772 |
||
773 |
||
249 | 774 |
unused_thms |
775 |
||
248
b90ff5abb437
added a proof that Positional ordering is equivalent to direct posix definition
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
776 |
end |