author | nipkow |
Wed, 25 May 2016 17:40:56 +0200 | |
changeset 63149 | f5dbab18c404 |
parent 63117 | acb6d72fc42e |
child 63155 | ea8540c71581 |
permissions | -rw-r--r-- |
49087 | 1 |
(* Title: HOL/Library/Sublist.thy |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
2 |
Author: Tobias Nipkow and Markus Wenzel, TU Muenchen |
49087 | 3 |
Author: Christian Sternagel, JAIST |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
4 |
*) |
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
5 |
|
60500 | 6 |
section \<open>List prefixes, suffixes, and homeomorphic embedding\<close> |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
7 |
|
49087 | 8 |
theory Sublist |
9 |
imports Main |
|
15131 | 10 |
begin |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
11 |
|
60500 | 12 |
subsection \<open>Prefix order on lists\<close> |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
13 |
|
63117 | 14 |
definition prefix :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
15 |
where "prefix xs ys \<longleftrightarrow> (\<exists>zs. ys = xs @ zs)" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
16 |
|
63117 | 17 |
definition strict_prefix :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
18 |
where "strict_prefix xs ys \<longleftrightarrow> prefix xs ys \<and> xs \<noteq> ys" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
19 |
|
63117 | 20 |
interpretation prefix_order: order prefix strict_prefix |
21 |
by standard (auto simp: prefix_def strict_prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
22 |
|
63117 | 23 |
interpretation prefix_bot: order_bot Nil prefix strict_prefix |
24 |
by standard (simp add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
25 |
|
63117 | 26 |
lemma prefixI [intro?]: "ys = xs @ zs \<Longrightarrow> prefix xs ys" |
27 |
unfolding prefix_def by blast |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
28 |
|
63117 | 29 |
lemma prefixE [elim?]: |
30 |
assumes "prefix xs ys" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
31 |
obtains zs where "ys = xs @ zs" |
63117 | 32 |
using assms unfolding prefix_def by blast |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
33 |
|
63117 | 34 |
lemma strict_prefixI' [intro?]: "ys = xs @ z # zs \<Longrightarrow> strict_prefix xs ys" |
35 |
unfolding strict_prefix_def prefix_def by blast |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
36 |
|
63117 | 37 |
lemma strict_prefixE' [elim?]: |
38 |
assumes "strict_prefix xs ys" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
39 |
obtains z zs where "ys = xs @ z # zs" |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
40 |
proof - |
63117 | 41 |
from \<open>strict_prefix xs ys\<close> obtain us where "ys = xs @ us" and "xs \<noteq> ys" |
42 |
unfolding strict_prefix_def prefix_def by blast |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
43 |
with that show ?thesis by (auto simp add: neq_Nil_conv) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
44 |
qed |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
45 |
|
63117 | 46 |
lemma strict_prefixI [intro?]: "prefix xs ys \<Longrightarrow> xs \<noteq> ys \<Longrightarrow> strict_prefix xs ys" |
47 |
unfolding strict_prefix_def by blast |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
48 |
|
63117 | 49 |
lemma strict_prefixE [elim?]: |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
50 |
fixes xs ys :: "'a list" |
63117 | 51 |
assumes "strict_prefix xs ys" |
52 |
obtains "prefix xs ys" and "xs \<noteq> ys" |
|
53 |
using assms unfolding strict_prefix_def by blast |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
54 |
|
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
55 |
|
60500 | 56 |
subsection \<open>Basic properties of prefixes\<close> |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
57 |
|
63117 | 58 |
theorem Nil_prefix [iff]: "prefix [] xs" |
59 |
by (simp add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
60 |
|
63117 | 61 |
theorem prefix_Nil [simp]: "(prefix xs []) = (xs = [])" |
62 |
by (induct xs) (simp_all add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
63 |
|
63117 | 64 |
lemma prefix_snoc [simp]: "prefix xs (ys @ [y]) \<longleftrightarrow> xs = ys @ [y] \<or> prefix xs ys" |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
65 |
proof |
63117 | 66 |
assume "prefix xs (ys @ [y])" |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
67 |
then obtain zs where zs: "ys @ [y] = xs @ zs" .. |
63117 | 68 |
show "xs = ys @ [y] \<or> prefix xs ys" |
69 |
by (metis append_Nil2 butlast_append butlast_snoc prefixI zs) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
70 |
next |
63117 | 71 |
assume "xs = ys @ [y] \<or> prefix xs ys" |
72 |
then show "prefix xs (ys @ [y])" |
|
73 |
by (metis prefix_order.eq_iff prefix_order.order_trans prefixI) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
74 |
qed |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
75 |
|
63117 | 76 |
lemma Cons_prefix_Cons [simp]: "prefix (x # xs) (y # ys) = (x = y \<and> prefix xs ys)" |
77 |
by (auto simp add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
78 |
|
63117 | 79 |
lemma prefix_code [code]: |
80 |
"prefix [] xs \<longleftrightarrow> True" |
|
81 |
"prefix (x # xs) [] \<longleftrightarrow> False" |
|
82 |
"prefix (x # xs) (y # ys) \<longleftrightarrow> x = y \<and> prefix xs ys" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
83 |
by simp_all |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
84 |
|
63117 | 85 |
lemma same_prefix_prefix [simp]: "prefix (xs @ ys) (xs @ zs) = prefix ys zs" |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
86 |
by (induct xs) simp_all |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
87 |
|
63117 | 88 |
lemma same_prefix_nil [iff]: "prefix (xs @ ys) xs = (ys = [])" |
89 |
by (metis append_Nil2 append_self_conv prefix_order.eq_iff prefixI) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
90 |
|
63117 | 91 |
lemma prefix_prefix [simp]: "prefix xs ys \<Longrightarrow> prefix xs (ys @ zs)" |
92 |
by (metis prefix_order.le_less_trans prefixI strict_prefixE strict_prefixI) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
93 |
|
63117 | 94 |
lemma append_prefixD: "prefix (xs @ ys) zs \<Longrightarrow> prefix xs zs" |
95 |
by (auto simp add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
96 |
|
63117 | 97 |
theorem prefix_Cons: "prefix xs (y # ys) = (xs = [] \<or> (\<exists>zs. xs = y # zs \<and> prefix zs ys))" |
98 |
by (cases xs) (auto simp add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
99 |
|
63117 | 100 |
theorem prefix_append: |
101 |
"prefix xs (ys @ zs) = (prefix xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefix us zs))" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
102 |
apply (induct zs rule: rev_induct) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
103 |
apply force |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
104 |
apply (simp del: append_assoc add: append_assoc [symmetric]) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
105 |
apply (metis append_eq_appendI) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
106 |
done |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
107 |
|
63117 | 108 |
lemma append_one_prefix: |
109 |
"prefix xs ys \<Longrightarrow> length xs < length ys \<Longrightarrow> prefix (xs @ [ys ! length xs]) ys" |
|
110 |
proof (unfold prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
111 |
assume a1: "\<exists>zs. ys = xs @ zs" |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
112 |
then obtain sk :: "'a list" where sk: "ys = xs @ sk" by fastforce |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
113 |
assume a2: "length xs < length ys" |
61076 | 114 |
have f1: "\<And>v. ([]::'a list) @ v = v" using append_Nil2 by simp |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
115 |
have "[] \<noteq> sk" using a1 a2 sk less_not_refl by force |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
116 |
hence "\<exists>v. xs @ hd sk # v = ys" using sk by (metis hd_Cons_tl) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
117 |
thus "\<exists>zs. ys = (xs @ [ys ! length xs]) @ zs" using f1 by fastforce |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
118 |
qed |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
119 |
|
63117 | 120 |
theorem prefix_length_le: "prefix xs ys \<Longrightarrow> length xs \<le> length ys" |
121 |
by (auto simp add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
122 |
|
63117 | 123 |
lemma prefix_same_cases: |
124 |
"prefix (xs\<^sub>1::'a list) ys \<Longrightarrow> prefix xs\<^sub>2 ys \<Longrightarrow> prefix xs\<^sub>1 xs\<^sub>2 \<or> prefix xs\<^sub>2 xs\<^sub>1" |
|
125 |
unfolding prefix_def by (force simp: append_eq_append_conv2) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
126 |
|
63117 | 127 |
lemma set_mono_prefix: "prefix xs ys \<Longrightarrow> set xs \<subseteq> set ys" |
128 |
by (auto simp add: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
129 |
|
63117 | 130 |
lemma take_is_prefix: "prefix (take n xs) xs" |
131 |
unfolding prefix_def by (metis append_take_drop_id) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
132 |
|
63117 | 133 |
lemma map_prefixI: "prefix xs ys \<Longrightarrow> prefix (map f xs) (map f ys)" |
134 |
by (auto simp: prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
135 |
|
63117 | 136 |
lemma prefix_length_less: "strict_prefix xs ys \<Longrightarrow> length xs < length ys" |
137 |
by (auto simp: strict_prefix_def prefix_def) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
138 |
|
63117 | 139 |
lemma strict_prefix_simps [simp, code]: |
140 |
"strict_prefix xs [] \<longleftrightarrow> False" |
|
141 |
"strict_prefix [] (x # xs) \<longleftrightarrow> True" |
|
142 |
"strict_prefix (x # xs) (y # ys) \<longleftrightarrow> x = y \<and> strict_prefix xs ys" |
|
143 |
by (simp_all add: strict_prefix_def cong: conj_cong) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
144 |
|
63117 | 145 |
lemma take_strict_prefix: "strict_prefix xs ys \<Longrightarrow> strict_prefix (take n xs) ys" |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
146 |
apply (induct n arbitrary: xs ys) |
59997 | 147 |
apply (case_tac ys; simp) |
63117 | 148 |
apply (metis prefix_order.less_trans strict_prefixI take_is_prefix) |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
149 |
done |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
150 |
|
63117 | 151 |
lemma not_prefix_cases: |
152 |
assumes pfx: "\<not> prefix ps ls" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
153 |
obtains |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
154 |
(c1) "ps \<noteq> []" and "ls = []" |
63117 | 155 |
| (c2) a as x xs where "ps = a#as" and "ls = x#xs" and "x = a" and "\<not> prefix as xs" |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
156 |
| (c3) a as x xs where "ps = a#as" and "ls = x#xs" and "x \<noteq> a" |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
157 |
proof (cases ps) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
158 |
case Nil |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
159 |
then show ?thesis using pfx by simp |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
160 |
next |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
161 |
case (Cons a as) |
60500 | 162 |
note c = \<open>ps = a#as\<close> |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
163 |
show ?thesis |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
164 |
proof (cases ls) |
63117 | 165 |
case Nil then show ?thesis by (metis append_Nil2 pfx c1 same_prefix_nil) |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
166 |
next |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
167 |
case (Cons x xs) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
168 |
show ?thesis |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
169 |
proof (cases "x = a") |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
170 |
case True |
63117 | 171 |
have "\<not> prefix as xs" using pfx c Cons True by simp |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
172 |
with c Cons True show ?thesis by (rule c2) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
173 |
next |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
174 |
case False |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
175 |
with c Cons show ?thesis by (rule c3) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
176 |
qed |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
177 |
qed |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
178 |
qed |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
179 |
|
63117 | 180 |
lemma not_prefix_induct [consumes 1, case_names Nil Neq Eq]: |
181 |
assumes np: "\<not> prefix ps ls" |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
182 |
and base: "\<And>x xs. P (x#xs) []" |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
183 |
and r1: "\<And>x xs y ys. x \<noteq> y \<Longrightarrow> P (x#xs) (y#ys)" |
63117 | 184 |
and r2: "\<And>x xs y ys. \<lbrakk> x = y; \<not> prefix xs ys; P xs ys \<rbrakk> \<Longrightarrow> P (x#xs) (y#ys)" |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
185 |
shows "P ps ls" using np |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
186 |
proof (induct ls arbitrary: ps) |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
187 |
case Nil then show ?case |
63117 | 188 |
by (auto simp: neq_Nil_conv elim!: not_prefix_cases intro!: base) |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
189 |
next |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
190 |
case (Cons y ys) |
63117 | 191 |
then have npfx: "\<not> prefix ps (y # ys)" by simp |
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
192 |
then obtain x xs where pv: "ps = x # xs" |
63117 | 193 |
by (rule not_prefix_cases) auto |
194 |
show ?case by (metis Cons.hyps Cons_prefix_Cons npfx pv r1 r2) |
|
55579
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
195 |
qed |
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
196 |
|
207538943038
reverted ba7392b52a7c: List_Prefix not needed anymore by codatatypes
traytel
parents:
54538
diff
changeset
|
197 |
|
60500 | 198 |
subsection \<open>Parallel lists\<close> |
10389 | 199 |
|
50516 | 200 |
definition parallel :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" (infixl "\<parallel>" 50) |
63117 | 201 |
where "(xs \<parallel> ys) = (\<not> prefix xs ys \<and> \<not> prefix ys xs)" |
10389 | 202 |
|
63117 | 203 |
lemma parallelI [intro]: "\<not> prefix xs ys \<Longrightarrow> \<not> prefix ys xs \<Longrightarrow> xs \<parallel> ys" |
25692 | 204 |
unfolding parallel_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
205 |
|
10389 | 206 |
lemma parallelE [elim]: |
25692 | 207 |
assumes "xs \<parallel> ys" |
63117 | 208 |
obtains "\<not> prefix xs ys \<and> \<not> prefix ys xs" |
25692 | 209 |
using assms unfolding parallel_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
210 |
|
63117 | 211 |
theorem prefix_cases: |
212 |
obtains "prefix xs ys" | "strict_prefix ys xs" | "xs \<parallel> ys" |
|
213 |
unfolding parallel_def strict_prefix_def by blast |
|
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
214 |
|
10389 | 215 |
theorem parallel_decomp: |
50516 | 216 |
"xs \<parallel> ys \<Longrightarrow> \<exists>as b bs c cs. b \<noteq> c \<and> xs = as @ b # bs \<and> ys = as @ c # cs" |
10408 | 217 |
proof (induct xs rule: rev_induct) |
11987 | 218 |
case Nil |
23254 | 219 |
then have False by auto |
220 |
then show ?case .. |
|
10408 | 221 |
next |
11987 | 222 |
case (snoc x xs) |
223 |
show ?case |
|
63117 | 224 |
proof (rule prefix_cases) |
225 |
assume le: "prefix xs ys" |
|
10408 | 226 |
then obtain ys' where ys: "ys = xs @ ys'" .. |
227 |
show ?thesis |
|
228 |
proof (cases ys') |
|
25564 | 229 |
assume "ys' = []" |
63117 | 230 |
then show ?thesis by (metis append_Nil2 parallelE prefixI snoc.prems ys) |
10389 | 231 |
next |
10408 | 232 |
fix c cs assume ys': "ys' = c # cs" |
54483 | 233 |
have "x \<noteq> c" using snoc.prems ys ys' by fastforce |
234 |
thus "\<exists>as b bs c cs. b \<noteq> c \<and> xs @ [x] = as @ b # bs \<and> ys = as @ c # cs" |
|
235 |
using ys ys' by blast |
|
10389 | 236 |
qed |
10408 | 237 |
next |
63117 | 238 |
assume "strict_prefix ys xs" |
239 |
then have "prefix ys (xs @ [x])" by (simp add: strict_prefix_def) |
|
11987 | 240 |
with snoc have False by blast |
23254 | 241 |
then show ?thesis .. |
10408 | 242 |
next |
243 |
assume "xs \<parallel> ys" |
|
11987 | 244 |
with snoc obtain as b bs c cs where neq: "(b::'a) \<noteq> c" |
10408 | 245 |
and xs: "xs = as @ b # bs" and ys: "ys = as @ c # cs" |
246 |
by blast |
|
247 |
from xs have "xs @ [x] = as @ b # (bs @ [x])" by simp |
|
248 |
with neq ys show ?thesis by blast |
|
10389 | 249 |
qed |
250 |
qed |
|
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
251 |
|
25564 | 252 |
lemma parallel_append: "a \<parallel> b \<Longrightarrow> a @ c \<parallel> b @ d" |
25692 | 253 |
apply (rule parallelI) |
254 |
apply (erule parallelE, erule conjE, |
|
63117 | 255 |
induct rule: not_prefix_induct, simp+)+ |
25692 | 256 |
done |
25299 | 257 |
|
25692 | 258 |
lemma parallel_appendI: "xs \<parallel> ys \<Longrightarrow> x = xs @ xs' \<Longrightarrow> y = ys @ ys' \<Longrightarrow> x \<parallel> y" |
259 |
by (simp add: parallel_append) |
|
25299 | 260 |
|
25692 | 261 |
lemma parallel_commute: "a \<parallel> b \<longleftrightarrow> b \<parallel> a" |
262 |
unfolding parallel_def by auto |
|
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
263 |
|
25356 | 264 |
|
60500 | 265 |
subsection \<open>Suffix order on lists\<close> |
17201 | 266 |
|
63149 | 267 |
definition suffix :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
268 |
where "suffix xs ys = (\<exists>zs. ys = zs @ xs)" |
|
49087 | 269 |
|
63149 | 270 |
definition strict_suffix :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
271 |
where "strict_suffix xs ys \<longleftrightarrow> (\<exists>us. ys = us @ xs \<and> us \<noteq> [])" |
|
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
272 |
|
63149 | 273 |
lemma strict_suffix_imp_suffix: |
274 |
"strict_suffix xs ys \<Longrightarrow> suffix xs ys" |
|
275 |
by (auto simp: suffix_def strict_suffix_def) |
|
49087 | 276 |
|
63149 | 277 |
lemma suffixI [intro?]: "ys = zs @ xs \<Longrightarrow> suffix xs ys" |
278 |
unfolding suffix_def by blast |
|
21305 | 279 |
|
63149 | 280 |
lemma suffixE [elim?]: |
281 |
assumes "suffix xs ys" |
|
49087 | 282 |
obtains zs where "ys = zs @ xs" |
63149 | 283 |
using assms unfolding suffix_def by blast |
21305 | 284 |
|
63149 | 285 |
lemma suffix_refl [iff]: "suffix xs xs" |
286 |
by (auto simp add: suffix_def) |
|
287 |
||
49087 | 288 |
lemma suffix_trans: |
289 |
"suffix xs ys \<Longrightarrow> suffix ys zs \<Longrightarrow> suffix xs zs" |
|
290 |
by (auto simp: suffix_def) |
|
63149 | 291 |
|
292 |
lemma strict_suffix_trans: |
|
293 |
"\<lbrakk>strict_suffix xs ys; strict_suffix ys zs\<rbrakk> \<Longrightarrow> strict_suffix xs zs" |
|
294 |
by (auto simp add: strict_suffix_def) |
|
49087 | 295 |
|
63149 | 296 |
lemma suffix_antisym: "\<lbrakk>suffix xs ys; suffix ys xs\<rbrakk> \<Longrightarrow> xs = ys" |
297 |
by (auto simp add: suffix_def) |
|
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
298 |
|
63149 | 299 |
lemma suffix_tl [simp]: "suffix (tl xs) xs" |
49087 | 300 |
by (induct xs) (auto simp: suffix_def) |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
301 |
|
63149 | 302 |
lemma strict_suffix_tl [simp]: "xs \<noteq> [] \<Longrightarrow> strict_suffix (tl xs) xs" |
303 |
by (induct xs) (auto simp: strict_suffix_def) |
|
304 |
||
305 |
lemma Nil_suffix [iff]: "suffix [] xs" |
|
306 |
by (simp add: suffix_def) |
|
49087 | 307 |
|
63149 | 308 |
lemma suffix_Nil [simp]: "(suffix xs []) = (xs = [])" |
309 |
by (auto simp add: suffix_def) |
|
310 |
||
311 |
lemma suffix_ConsI: "suffix xs ys \<Longrightarrow> suffix xs (y # ys)" |
|
312 |
by (auto simp add: suffix_def) |
|
313 |
||
314 |
lemma suffix_ConsD: "suffix (x # xs) ys \<Longrightarrow> suffix xs ys" |
|
315 |
by (auto simp add: suffix_def) |
|
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
316 |
|
63149 | 317 |
lemma suffix_appendI: "suffix xs ys \<Longrightarrow> suffix xs (zs @ ys)" |
318 |
by (auto simp add: suffix_def) |
|
319 |
||
320 |
lemma suffix_appendD: "suffix (zs @ xs) ys \<Longrightarrow> suffix xs ys" |
|
321 |
by (auto simp add: suffix_def) |
|
49087 | 322 |
|
63149 | 323 |
lemma strict_suffix_set_subset: "strict_suffix xs ys \<Longrightarrow> set xs \<subseteq> set ys" |
324 |
by (auto simp: strict_suffix_def) |
|
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
325 |
|
63149 | 326 |
lemma suffix_set_subset: "suffix xs ys \<Longrightarrow> set xs \<subseteq> set ys" |
327 |
by (auto simp: suffix_def) |
|
49087 | 328 |
|
63149 | 329 |
lemma suffix_ConsD2: "suffix (x # xs) (y # ys) \<Longrightarrow> suffix xs ys" |
21305 | 330 |
proof - |
63149 | 331 |
assume "suffix (x # xs) (y # ys)" |
49107 | 332 |
then obtain zs where "y # ys = zs @ x # xs" .. |
49087 | 333 |
then show ?thesis |
63149 | 334 |
by (induct zs) (auto intro!: suffix_appendI suffix_ConsI) |
21305 | 335 |
qed |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
336 |
|
63149 | 337 |
lemma suffix_to_prefix [code]: "suffix xs ys \<longleftrightarrow> prefix (rev xs) (rev ys)" |
49087 | 338 |
proof |
63149 | 339 |
assume "suffix xs ys" |
49087 | 340 |
then obtain zs where "ys = zs @ xs" .. |
341 |
then have "rev ys = rev xs @ rev zs" by simp |
|
63117 | 342 |
then show "prefix (rev xs) (rev ys)" .. |
49087 | 343 |
next |
63117 | 344 |
assume "prefix (rev xs) (rev ys)" |
49087 | 345 |
then obtain zs where "rev ys = rev xs @ zs" .. |
346 |
then have "rev (rev ys) = rev zs @ rev (rev xs)" by simp |
|
347 |
then have "ys = rev zs @ xs" by simp |
|
63149 | 348 |
then show "suffix xs ys" .. |
21305 | 349 |
qed |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
350 |
|
63149 | 351 |
lemma distinct_suffix: "distinct ys \<Longrightarrow> suffix xs ys \<Longrightarrow> distinct xs" |
352 |
by (clarsimp elim!: suffixE) |
|
17201 | 353 |
|
63149 | 354 |
lemma suffix_map: "suffix xs ys \<Longrightarrow> suffix (map f xs) (map f ys)" |
355 |
by (auto elim!: suffixE intro: suffixI) |
|
25299 | 356 |
|
63149 | 357 |
lemma suffix_drop: "suffix (drop n as) as" |
358 |
unfolding suffix_def |
|
25692 | 359 |
apply (rule exI [where x = "take n as"]) |
360 |
apply simp |
|
361 |
done |
|
25299 | 362 |
|
63149 | 363 |
lemma suffix_take: "suffix xs ys \<Longrightarrow> ys = take (length ys - length xs) ys @ xs" |
364 |
by (auto elim!: suffixE) |
|
25299 | 365 |
|
63149 | 366 |
lemma strict_suffix_reflclp_conv: "strict_suffix\<^sup>=\<^sup>= = suffix" |
367 |
by (intro ext) (auto simp: suffix_def strict_suffix_def) |
|
368 |
||
369 |
lemma suffix_lists: "suffix xs ys \<Longrightarrow> ys \<in> lists A \<Longrightarrow> xs \<in> lists A" |
|
370 |
unfolding suffix_def by auto |
|
49087 | 371 |
|
63117 | 372 |
lemma parallelD1: "x \<parallel> y \<Longrightarrow> \<not> prefix x y" |
25692 | 373 |
by blast |
25299 | 374 |
|
63117 | 375 |
lemma parallelD2: "x \<parallel> y \<Longrightarrow> \<not> prefix y x" |
25692 | 376 |
by blast |
25355 | 377 |
|
378 |
lemma parallel_Nil1 [simp]: "\<not> x \<parallel> []" |
|
25692 | 379 |
unfolding parallel_def by simp |
25355 | 380 |
|
25299 | 381 |
lemma parallel_Nil2 [simp]: "\<not> [] \<parallel> x" |
25692 | 382 |
unfolding parallel_def by simp |
25299 | 383 |
|
25564 | 384 |
lemma Cons_parallelI1: "a \<noteq> b \<Longrightarrow> a # as \<parallel> b # bs" |
25692 | 385 |
by auto |
25299 | 386 |
|
25564 | 387 |
lemma Cons_parallelI2: "\<lbrakk> a = b; as \<parallel> bs \<rbrakk> \<Longrightarrow> a # as \<parallel> b # bs" |
63117 | 388 |
by (metis Cons_prefix_Cons parallelE parallelI) |
25665 | 389 |
|
25299 | 390 |
lemma not_equal_is_parallel: |
391 |
assumes neq: "xs \<noteq> ys" |
|
25356 | 392 |
and len: "length xs = length ys" |
393 |
shows "xs \<parallel> ys" |
|
25299 | 394 |
using len neq |
25355 | 395 |
proof (induct rule: list_induct2) |
26445 | 396 |
case Nil |
25356 | 397 |
then show ?case by simp |
25299 | 398 |
next |
26445 | 399 |
case (Cons a as b bs) |
25355 | 400 |
have ih: "as \<noteq> bs \<Longrightarrow> as \<parallel> bs" by fact |
25299 | 401 |
show ?case |
402 |
proof (cases "a = b") |
|
25355 | 403 |
case True |
26445 | 404 |
then have "as \<noteq> bs" using Cons by simp |
25355 | 405 |
then show ?thesis by (rule Cons_parallelI2 [OF True ih]) |
25299 | 406 |
next |
407 |
case False |
|
25355 | 408 |
then show ?thesis by (rule Cons_parallelI1) |
25299 | 409 |
qed |
410 |
qed |
|
22178 | 411 |
|
49087 | 412 |
|
60500 | 413 |
subsection \<open>Homeomorphic embedding on lists\<close> |
49087 | 414 |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
415 |
inductive list_emb :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
49087 | 416 |
for P :: "('a \<Rightarrow> 'a \<Rightarrow> bool)" |
417 |
where |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
418 |
list_emb_Nil [intro, simp]: "list_emb P [] ys" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
419 |
| list_emb_Cons [intro] : "list_emb P xs ys \<Longrightarrow> list_emb P xs (y#ys)" |
57498
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
420 |
| list_emb_Cons2 [intro]: "P x y \<Longrightarrow> list_emb P xs ys \<Longrightarrow> list_emb P (x#xs) (y#ys)" |
50516 | 421 |
|
57499
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
422 |
lemma list_emb_mono: |
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
423 |
assumes "\<And>x y. P x y \<longrightarrow> Q x y" |
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
424 |
shows "list_emb P xs ys \<longrightarrow> list_emb Q xs ys" |
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
425 |
proof |
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
426 |
assume "list_emb P xs ys" |
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
427 |
then show "list_emb Q xs ys" by (induct) (auto simp: assms) |
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
428 |
qed |
7e22776f2d32
added monotonicity lemma for list embedding
Christian Sternagel
parents:
57498
diff
changeset
|
429 |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
430 |
lemma list_emb_Nil2 [simp]: |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
431 |
assumes "list_emb P xs []" shows "xs = []" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
432 |
using assms by (cases rule: list_emb.cases) auto |
49087 | 433 |
|
57498
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
434 |
lemma list_emb_refl: |
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
435 |
assumes "\<And>x. x \<in> set xs \<Longrightarrow> P x x" |
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
436 |
shows "list_emb P xs xs" |
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
437 |
using assms by (induct xs) auto |
49087 | 438 |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
439 |
lemma list_emb_Cons_Nil [simp]: "list_emb P (x#xs) [] = False" |
49087 | 440 |
proof - |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
441 |
{ assume "list_emb P (x#xs) []" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
442 |
from list_emb_Nil2 [OF this] have False by simp |
49087 | 443 |
} moreover { |
444 |
assume False |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
445 |
then have "list_emb P (x#xs) []" by simp |
49087 | 446 |
} ultimately show ?thesis by blast |
447 |
qed |
|
448 |
||
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
449 |
lemma list_emb_append2 [intro]: "list_emb P xs ys \<Longrightarrow> list_emb P xs (zs @ ys)" |
49087 | 450 |
by (induct zs) auto |
451 |
||
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
452 |
lemma list_emb_prefix [intro]: |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
453 |
assumes "list_emb P xs ys" shows "list_emb P xs (ys @ zs)" |
49087 | 454 |
using assms |
455 |
by (induct arbitrary: zs) auto |
|
456 |
||
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
457 |
lemma list_emb_ConsD: |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
458 |
assumes "list_emb P (x#xs) ys" |
57498
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
459 |
shows "\<exists>us v vs. ys = us @ v # vs \<and> P x v \<and> list_emb P xs vs" |
49087 | 460 |
using assms |
49107 | 461 |
proof (induct x \<equiv> "x # xs" ys arbitrary: x xs) |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
462 |
case list_emb_Cons |
49107 | 463 |
then show ?case by (metis append_Cons) |
49087 | 464 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
465 |
case (list_emb_Cons2 x y xs ys) |
54483 | 466 |
then show ?case by blast |
49087 | 467 |
qed |
468 |
||
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
469 |
lemma list_emb_appendD: |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
470 |
assumes "list_emb P (xs @ ys) zs" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
471 |
shows "\<exists>us vs. zs = us @ vs \<and> list_emb P xs us \<and> list_emb P ys vs" |
49087 | 472 |
using assms |
473 |
proof (induction xs arbitrary: ys zs) |
|
49107 | 474 |
case Nil then show ?case by auto |
49087 | 475 |
next |
476 |
case (Cons x xs) |
|
54483 | 477 |
then obtain us v vs where |
57498
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
478 |
zs: "zs = us @ v # vs" and p: "P x v" and lh: "list_emb P (xs @ ys) vs" |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
479 |
by (auto dest: list_emb_ConsD) |
54483 | 480 |
obtain sk\<^sub>0 :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" and sk\<^sub>1 :: "'a list \<Rightarrow> 'a list \<Rightarrow> 'a list" where |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
481 |
sk: "\<forall>x\<^sub>0 x\<^sub>1. \<not> list_emb P (xs @ x\<^sub>0) x\<^sub>1 \<or> sk\<^sub>0 x\<^sub>0 x\<^sub>1 @ sk\<^sub>1 x\<^sub>0 x\<^sub>1 = x\<^sub>1 \<and> list_emb P xs (sk\<^sub>0 x\<^sub>0 x\<^sub>1) \<and> list_emb P x\<^sub>0 (sk\<^sub>1 x\<^sub>0 x\<^sub>1)" |
54483 | 482 |
using Cons(1) by (metis (no_types)) |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
483 |
hence "\<forall>x\<^sub>2. list_emb P (x # xs) (x\<^sub>2 @ v # sk\<^sub>0 ys vs)" using p lh by auto |
54483 | 484 |
thus ?case using lh zs sk by (metis (no_types) append_Cons append_assoc) |
49087 | 485 |
qed |
486 |
||
63149 | 487 |
lemma list_emb_strict_suffix: |
488 |
assumes "list_emb P xs ys" and "strict_suffix ys zs" |
|
489 |
shows "list_emb P xs zs" |
|
490 |
using assms(2) and list_emb_append2 [OF assms(1)] by (auto simp: strict_suffix_def) |
|
491 |
||
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
492 |
lemma list_emb_suffix: |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
493 |
assumes "list_emb P xs ys" and "suffix ys zs" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
494 |
shows "list_emb P xs zs" |
63149 | 495 |
using assms and list_emb_strict_suffix |
496 |
unfolding strict_suffix_reflclp_conv[symmetric] by auto |
|
49087 | 497 |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
498 |
lemma list_emb_length: "list_emb P xs ys \<Longrightarrow> length xs \<le> length ys" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
499 |
by (induct rule: list_emb.induct) auto |
49087 | 500 |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
501 |
lemma list_emb_trans: |
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
502 |
assumes "\<And>x y z. \<lbrakk>x \<in> set xs; y \<in> set ys; z \<in> set zs; P x y; P y z\<rbrakk> \<Longrightarrow> P x z" |
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
503 |
shows "\<lbrakk>list_emb P xs ys; list_emb P ys zs\<rbrakk> \<Longrightarrow> list_emb P xs zs" |
50516 | 504 |
proof - |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
505 |
assume "list_emb P xs ys" and "list_emb P ys zs" |
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
506 |
then show "list_emb P xs zs" using assms |
49087 | 507 |
proof (induction arbitrary: zs) |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
508 |
case list_emb_Nil show ?case by blast |
49087 | 509 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
510 |
case (list_emb_Cons xs ys y) |
60500 | 511 |
from list_emb_ConsD [OF \<open>list_emb P (y#ys) zs\<close>] obtain us v vs |
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
512 |
where zs: "zs = us @ v # vs" and "P\<^sup>=\<^sup>= y v" and "list_emb P ys vs" by blast |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
513 |
then have "list_emb P ys (v#vs)" by blast |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
514 |
then have "list_emb P ys zs" unfolding zs by (rule list_emb_append2) |
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
515 |
from list_emb_Cons.IH [OF this] and list_emb_Cons.prems show ?case by auto |
49087 | 516 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
517 |
case (list_emb_Cons2 x y xs ys) |
60500 | 518 |
from list_emb_ConsD [OF \<open>list_emb P (y#ys) zs\<close>] obtain us v vs |
57498
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
519 |
where zs: "zs = us @ v # vs" and "P y v" and "list_emb P ys vs" by blast |
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
520 |
with list_emb_Cons2 have "list_emb P xs vs" by auto |
57498
ea44ec62a574
no built-in reflexivity of list embedding (which is more standard; now embedding is reflexive whenever the base-order is)
Christian Sternagel
parents:
57497
diff
changeset
|
521 |
moreover have "P x v" |
49087 | 522 |
proof - |
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
523 |
from zs have "v \<in> set zs" by auto |
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
524 |
moreover have "x \<in> set (x#xs)" and "y \<in> set (y#ys)" by simp_all |
50516 | 525 |
ultimately show ?thesis |
60500 | 526 |
using \<open>P x y\<close> and \<open>P y v\<close> and list_emb_Cons2 |
50516 | 527 |
by blast |
49087 | 528 |
qed |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
529 |
ultimately have "list_emb P (x#xs) (v#vs)" by blast |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
530 |
then show ?case unfolding zs by (rule list_emb_append2) |
49087 | 531 |
qed |
532 |
qed |
|
533 |
||
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
534 |
lemma list_emb_set: |
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
535 |
assumes "list_emb P xs ys" and "x \<in> set xs" |
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
536 |
obtains y where "y \<in> set ys" and "P x y" |
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
537 |
using assms by (induct) auto |
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
538 |
|
49087 | 539 |
|
60500 | 540 |
subsection \<open>Sublists (special case of homeomorphic embedding)\<close> |
49087 | 541 |
|
50516 | 542 |
abbreviation sublisteq :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
543 |
where "sublisteq xs ys \<equiv> list_emb (op =) xs ys" |
49087 | 544 |
|
50516 | 545 |
lemma sublisteq_Cons2: "sublisteq xs ys \<Longrightarrow> sublisteq (x#xs) (x#ys)" by auto |
49087 | 546 |
|
50516 | 547 |
lemma sublisteq_same_length: |
548 |
assumes "sublisteq xs ys" and "length xs = length ys" shows "xs = ys" |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
549 |
using assms by (induct) (auto dest: list_emb_length) |
49087 | 550 |
|
50516 | 551 |
lemma not_sublisteq_length [simp]: "length ys < length xs \<Longrightarrow> \<not> sublisteq xs ys" |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
552 |
by (metis list_emb_length linorder_not_less) |
49087 | 553 |
|
554 |
lemma [code]: |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
555 |
"list_emb P [] ys \<longleftrightarrow> True" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
556 |
"list_emb P (x#xs) [] \<longleftrightarrow> False" |
49087 | 557 |
by (simp_all) |
558 |
||
50516 | 559 |
lemma sublisteq_Cons': "sublisteq (x#xs) ys \<Longrightarrow> sublisteq xs ys" |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
560 |
by (induct xs, simp, blast dest: list_emb_ConsD) |
49087 | 561 |
|
50516 | 562 |
lemma sublisteq_Cons2': |
563 |
assumes "sublisteq (x#xs) (x#ys)" shows "sublisteq xs ys" |
|
564 |
using assms by (cases) (rule sublisteq_Cons') |
|
49087 | 565 |
|
50516 | 566 |
lemma sublisteq_Cons2_neq: |
567 |
assumes "sublisteq (x#xs) (y#ys)" |
|
568 |
shows "x \<noteq> y \<Longrightarrow> sublisteq (x#xs) ys" |
|
49087 | 569 |
using assms by (cases) auto |
570 |
||
50516 | 571 |
lemma sublisteq_Cons2_iff [simp, code]: |
572 |
"sublisteq (x#xs) (y#ys) = (if x = y then sublisteq xs ys else sublisteq (x#xs) ys)" |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
573 |
by (metis list_emb_Cons sublisteq_Cons2 sublisteq_Cons2' sublisteq_Cons2_neq) |
49087 | 574 |
|
50516 | 575 |
lemma sublisteq_append': "sublisteq (zs @ xs) (zs @ ys) \<longleftrightarrow> sublisteq xs ys" |
49087 | 576 |
by (induct zs) simp_all |
577 |
||
50516 | 578 |
lemma sublisteq_refl [simp, intro!]: "sublisteq xs xs" by (induct xs) simp_all |
49087 | 579 |
|
50516 | 580 |
lemma sublisteq_antisym: |
581 |
assumes "sublisteq xs ys" and "sublisteq ys xs" |
|
49087 | 582 |
shows "xs = ys" |
583 |
using assms |
|
584 |
proof (induct) |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
585 |
case list_emb_Nil |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
586 |
from list_emb_Nil2 [OF this] show ?case by simp |
49087 | 587 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
588 |
case list_emb_Cons2 |
54483 | 589 |
thus ?case by simp |
49087 | 590 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
591 |
case list_emb_Cons |
54483 | 592 |
hence False using sublisteq_Cons' by fastforce |
593 |
thus ?case .. |
|
49087 | 594 |
qed |
595 |
||
50516 | 596 |
lemma sublisteq_trans: "sublisteq xs ys \<Longrightarrow> sublisteq ys zs \<Longrightarrow> sublisteq xs zs" |
57500
5a8b3e9d82a4
weaker assumption for "list_emb_trans"; added lemma
Christian Sternagel
parents:
57499
diff
changeset
|
597 |
by (rule list_emb_trans [of _ _ _ "op ="]) auto |
49087 | 598 |
|
50516 | 599 |
lemma sublisteq_append_le_same_iff: "sublisteq (xs @ ys) ys \<longleftrightarrow> xs = []" |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
600 |
by (auto dest: list_emb_length) |
49087 | 601 |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
602 |
lemma list_emb_append_mono: |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
603 |
"\<lbrakk> list_emb P xs xs'; list_emb P ys ys' \<rbrakk> \<Longrightarrow> list_emb P (xs@ys) (xs'@ys')" |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
604 |
apply (induct rule: list_emb.induct) |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
605 |
apply (metis eq_Nil_appendI list_emb_append2) |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
606 |
apply (metis append_Cons list_emb_Cons) |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
607 |
apply (metis append_Cons list_emb_Cons2) |
49107 | 608 |
done |
49087 | 609 |
|
610 |
||
60500 | 611 |
subsection \<open>Appending elements\<close> |
49087 | 612 |
|
50516 | 613 |
lemma sublisteq_append [simp]: |
614 |
"sublisteq (xs @ zs) (ys @ zs) \<longleftrightarrow> sublisteq xs ys" (is "?l = ?r") |
|
49087 | 615 |
proof |
50516 | 616 |
{ fix xs' ys' xs ys zs :: "'a list" assume "sublisteq xs' ys'" |
617 |
then have "xs' = xs @ zs & ys' = ys @ zs \<longrightarrow> sublisteq xs ys" |
|
49087 | 618 |
proof (induct arbitrary: xs ys zs) |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
619 |
case list_emb_Nil show ?case by simp |
49087 | 620 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
621 |
case (list_emb_Cons xs' ys' x) |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
622 |
{ assume "ys=[]" then have ?case using list_emb_Cons(1) by auto } |
49087 | 623 |
moreover |
624 |
{ fix us assume "ys = x#us" |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
625 |
then have ?case using list_emb_Cons(2) by(simp add: list_emb.list_emb_Cons) } |
49087 | 626 |
ultimately show ?case by (auto simp:Cons_eq_append_conv) |
627 |
next |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
628 |
case (list_emb_Cons2 x y xs' ys') |
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
629 |
{ assume "xs=[]" then have ?case using list_emb_Cons2(1) by auto } |
49087 | 630 |
moreover |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
631 |
{ fix us vs assume "xs=x#us" "ys=x#vs" then have ?case using list_emb_Cons2 by auto} |
49087 | 632 |
moreover |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
633 |
{ fix us assume "xs=x#us" "ys=[]" then have ?case using list_emb_Cons2(2) by bestsimp } |
60500 | 634 |
ultimately show ?case using \<open>op = x y\<close> by (auto simp: Cons_eq_append_conv) |
49087 | 635 |
qed } |
636 |
moreover assume ?l |
|
637 |
ultimately show ?r by blast |
|
638 |
next |
|
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
639 |
assume ?r then show ?l by (metis list_emb_append_mono sublisteq_refl) |
49087 | 640 |
qed |
641 |
||
50516 | 642 |
lemma sublisteq_drop_many: "sublisteq xs ys \<Longrightarrow> sublisteq xs (zs @ ys)" |
49087 | 643 |
by (induct zs) auto |
644 |
||
50516 | 645 |
lemma sublisteq_rev_drop_many: "sublisteq xs ys \<Longrightarrow> sublisteq xs (ys @ zs)" |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
646 |
by (metis append_Nil2 list_emb_Nil list_emb_append_mono) |
49087 | 647 |
|
648 |
||
60500 | 649 |
subsection \<open>Relation to standard list operations\<close> |
49087 | 650 |
|
50516 | 651 |
lemma sublisteq_map: |
652 |
assumes "sublisteq xs ys" shows "sublisteq (map f xs) (map f ys)" |
|
49087 | 653 |
using assms by (induct) auto |
654 |
||
50516 | 655 |
lemma sublisteq_filter_left [simp]: "sublisteq (filter P xs) xs" |
49087 | 656 |
by (induct xs) auto |
657 |
||
50516 | 658 |
lemma sublisteq_filter [simp]: |
659 |
assumes "sublisteq xs ys" shows "sublisteq (filter P xs) (filter P ys)" |
|
54483 | 660 |
using assms by induct auto |
49087 | 661 |
|
50516 | 662 |
lemma "sublisteq xs ys \<longleftrightarrow> (\<exists>N. xs = sublist ys N)" (is "?L = ?R") |
49087 | 663 |
proof |
664 |
assume ?L |
|
49107 | 665 |
then show ?R |
49087 | 666 |
proof (induct) |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
667 |
case list_emb_Nil show ?case by (metis sublist_empty) |
49087 | 668 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
669 |
case (list_emb_Cons xs ys x) |
49087 | 670 |
then obtain N where "xs = sublist ys N" by blast |
49107 | 671 |
then have "xs = sublist (x#ys) (Suc ` N)" |
49087 | 672 |
by (clarsimp simp add:sublist_Cons inj_image_mem_iff) |
49107 | 673 |
then show ?case by blast |
49087 | 674 |
next |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
675 |
case (list_emb_Cons2 x y xs ys) |
49087 | 676 |
then obtain N where "xs = sublist ys N" by blast |
49107 | 677 |
then have "x#xs = sublist (x#ys) (insert 0 (Suc ` N))" |
49087 | 678 |
by (clarsimp simp add:sublist_Cons inj_image_mem_iff) |
57497
4106a2bc066a
renamed "list_hembeq" into slightly shorter "list_emb"
Christian Sternagel
parents:
55579
diff
changeset
|
679 |
moreover from list_emb_Cons2 have "x = y" by simp |
50516 | 680 |
ultimately show ?case by blast |
49087 | 681 |
qed |
682 |
next |
|
683 |
assume ?R |
|
684 |
then obtain N where "xs = sublist ys N" .. |
|
50516 | 685 |
moreover have "sublisteq (sublist ys N) ys" |
49107 | 686 |
proof (induct ys arbitrary: N) |
49087 | 687 |
case Nil show ?case by simp |
688 |
next |
|
49107 | 689 |
case Cons then show ?case by (auto simp: sublist_Cons) |
49087 | 690 |
qed |
691 |
ultimately show ?L by simp |
|
692 |
qed |
|
693 |
||
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
694 |
end |