author | Christian Sternagel |
Wed, 29 Aug 2012 12:24:26 +0900 | |
changeset 49084 | e3973567ed4f |
parent 49083 | 01081bca31b6 |
permissions | -rw-r--r-- |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
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 |
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
3 |
*) |
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
4 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
5 |
header {* List prefixes, suffixes, and embedding*} |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
6 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
7 |
theory Sublist |
30663
0b6aff7451b2
Main is (Complex_Main) base entry point in library theories
haftmann
parents:
28562
diff
changeset
|
8 |
imports List Main |
15131 | 9 |
begin |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
10 |
|
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
11 |
subsection {* Prefix order on lists *} |
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
12 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
13 |
definition prefixeq :: "'a list => 'a list => bool" where |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
14 |
"prefixeq xs ys \<longleftrightarrow> (\<exists>zs. ys = xs @ zs)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
15 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
16 |
definition prefix :: "'a list => 'a list => bool" where |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
17 |
"prefix xs ys \<longleftrightarrow> prefixeq xs ys \<and> xs \<noteq> ys" |
25764 | 18 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
19 |
interpretation prefix_order: order prefixeq prefix |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
20 |
by default (auto simp: prefixeq_def prefix_def) |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
21 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
22 |
interpretation prefix_bot: bot prefixeq prefix Nil |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
23 |
by default (simp add: prefixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
24 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
25 |
lemma prefixeqI [intro?]: "ys = xs @ zs ==> prefixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
26 |
unfolding prefixeq_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
27 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
28 |
lemma prefixeqE [elim?]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
29 |
assumes "prefixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
30 |
obtains zs where "ys = xs @ zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
31 |
using assms unfolding prefixeq_def by blast |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
32 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
33 |
lemma prefixI' [intro?]: "ys = xs @ z # zs ==> prefix xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
34 |
unfolding prefix_def prefixeq_def by blast |
37474 | 35 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
36 |
lemma prefixE' [elim?]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
37 |
assumes "prefix xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
38 |
obtains z zs where "ys = xs @ z # zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
39 |
proof - |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
40 |
from `prefix xs ys` obtain us where "ys = xs @ us" and "xs \<noteq> ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
41 |
unfolding prefix_def prefixeq_def by blast |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
42 |
with that show ?thesis by (auto simp add: neq_Nil_conv) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
43 |
qed |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
44 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
45 |
lemma prefixI [intro?]: "prefixeq xs ys ==> xs \<noteq> ys ==> prefix xs ys" |
18730 | 46 |
unfolding prefix_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
47 |
|
21305 | 48 |
lemma prefixE [elim?]: |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
49 |
fixes xs ys :: "'a list" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
50 |
assumes "prefix xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
51 |
obtains "prefixeq xs ys" and "xs \<noteq> ys" |
23394 | 52 |
using assms unfolding prefix_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
53 |
|
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
54 |
|
10389 | 55 |
subsection {* Basic properties of prefixes *} |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
56 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
57 |
theorem Nil_prefixeq [iff]: "prefixeq [] xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
58 |
by (simp add: prefixeq_def) |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
59 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
60 |
theorem prefixeq_Nil [simp]: "(prefixeq xs []) = (xs = [])" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
61 |
by (induct xs) (simp_all add: prefixeq_def) |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
62 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
63 |
lemma prefixeq_snoc [simp]: "prefixeq xs (ys @ [y]) \<longleftrightarrow> xs = ys @ [y] \<or> prefixeq xs ys" |
10389 | 64 |
proof |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
65 |
assume "prefixeq xs (ys @ [y])" |
10389 | 66 |
then obtain zs where zs: "ys @ [y] = xs @ zs" .. |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
67 |
show "xs = ys @ [y] \<or> prefixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
68 |
by (metis append_Nil2 butlast_append butlast_snoc prefixeqI zs) |
10389 | 69 |
next |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
70 |
assume "xs = ys @ [y] \<or> prefixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
71 |
then show "prefixeq xs (ys @ [y])" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
72 |
by (metis prefix_order.eq_iff prefix_order.order_trans prefixeqI) |
10389 | 73 |
qed |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
74 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
75 |
lemma Cons_prefixeq_Cons [simp]: "prefixeq (x # xs) (y # ys) = (x = y \<and> prefixeq xs ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
76 |
by (auto simp add: prefixeq_def) |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
77 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
78 |
lemma prefixeq_code [code]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
79 |
"prefixeq [] xs \<longleftrightarrow> True" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
80 |
"prefixeq (x # xs) [] \<longleftrightarrow> False" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
81 |
"prefixeq (x # xs) (y # ys) \<longleftrightarrow> x = y \<and> prefixeq xs ys" |
37474 | 82 |
by simp_all |
83 |
||
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
84 |
lemma same_prefixeq_prefixeq [simp]: "prefixeq (xs @ ys) (xs @ zs) = prefixeq ys zs" |
10389 | 85 |
by (induct xs) simp_all |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
86 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
87 |
lemma same_prefixeq_nil [iff]: "prefixeq (xs @ ys) xs = (ys = [])" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
88 |
by (metis append_Nil2 append_self_conv prefix_order.eq_iff prefixeqI) |
25665 | 89 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
90 |
lemma prefixeq_prefixeq [simp]: "prefixeq xs ys ==> prefixeq xs (ys @ zs)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
91 |
by (metis prefix_order.le_less_trans prefixeqI prefixE prefixI) |
25665 | 92 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
93 |
lemma append_prefixeqD: "prefixeq (xs @ ys) zs \<Longrightarrow> prefixeq xs zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
94 |
by (auto simp add: prefixeq_def) |
14300 | 95 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
96 |
theorem prefixeq_Cons: "prefixeq xs (y # ys) = (xs = [] \<or> (\<exists>zs. xs = y # zs \<and> prefixeq zs ys))" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
97 |
by (cases xs) (auto simp add: prefixeq_def) |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
98 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
99 |
theorem prefixeq_append: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
100 |
"prefixeq xs (ys @ zs) = (prefixeq xs ys \<or> (\<exists>us. xs = ys @ us \<and> prefixeq us zs))" |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
101 |
apply (induct zs rule: rev_induct) |
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
102 |
apply force |
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
103 |
apply (simp del: append_assoc add: append_assoc [symmetric]) |
25564 | 104 |
apply (metis append_eq_appendI) |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
105 |
done |
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
106 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
107 |
lemma append_one_prefixeq: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
108 |
"prefixeq xs ys ==> length xs < length ys ==> prefixeq (xs @ [ys ! length xs]) ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
109 |
unfolding prefixeq_def |
25692 | 110 |
by (metis Cons_eq_appendI append_eq_appendI append_eq_conv_conj |
111 |
eq_Nil_appendI nth_drop') |
|
25665 | 112 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
113 |
theorem prefixeq_length_le: "prefixeq xs ys ==> length xs \<le> length ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
114 |
by (auto simp add: prefixeq_def) |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
115 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
116 |
lemma prefixeq_same_cases: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
117 |
"prefixeq (xs\<^isub>1::'a list) ys \<Longrightarrow> prefixeq xs\<^isub>2 ys \<Longrightarrow> prefixeq xs\<^isub>1 xs\<^isub>2 \<or> prefixeq xs\<^isub>2 xs\<^isub>1" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
118 |
unfolding prefixeq_def by (metis append_eq_append_conv2) |
25665 | 119 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
120 |
lemma set_mono_prefixeq: "prefixeq xs ys \<Longrightarrow> set xs \<subseteq> set ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
121 |
by (auto simp add: prefixeq_def) |
14300 | 122 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
123 |
lemma take_is_prefixeq: "prefixeq (take n xs) xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
124 |
unfolding prefixeq_def by (metis append_take_drop_id) |
25665 | 125 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
126 |
lemma map_prefixeqI: "prefixeq xs ys \<Longrightarrow> prefixeq (map f xs) (map f ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
127 |
by (auto simp: prefixeq_def) |
25322 | 128 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
129 |
lemma prefixeq_length_less: "prefix xs ys \<Longrightarrow> length xs < length ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
130 |
by (auto simp: prefix_def prefixeq_def) |
25665 | 131 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
132 |
lemma prefix_simps [simp, code]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
133 |
"prefix xs [] \<longleftrightarrow> False" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
134 |
"prefix [] (x # xs) \<longleftrightarrow> True" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
135 |
"prefix (x # xs) (y # ys) \<longleftrightarrow> x = y \<and> prefix xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
136 |
by (simp_all add: prefix_def cong: conj_cong) |
25299 | 137 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
138 |
lemma take_prefix: "prefix xs ys \<Longrightarrow> prefix (take n xs) ys" |
25692 | 139 |
apply (induct n arbitrary: xs ys) |
140 |
apply (case_tac ys, simp_all)[1] |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
141 |
apply (metis prefix_order.less_trans prefixI take_is_prefixeq) |
25692 | 142 |
done |
25299 | 143 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
144 |
lemma not_prefixeq_cases: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
145 |
assumes pfx: "\<not> prefixeq ps ls" |
25356 | 146 |
obtains |
147 |
(c1) "ps \<noteq> []" and "ls = []" |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
148 |
| (c2) a as x xs where "ps = a#as" and "ls = x#xs" and "x = a" and "\<not> prefixeq as xs" |
25356 | 149 |
| (c3) a as x xs where "ps = a#as" and "ls = x#xs" and "x \<noteq> a" |
25299 | 150 |
proof (cases ps) |
25692 | 151 |
case Nil then show ?thesis using pfx by simp |
25299 | 152 |
next |
153 |
case (Cons a as) |
|
25692 | 154 |
note c = `ps = a#as` |
25299 | 155 |
show ?thesis |
156 |
proof (cases ls) |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
157 |
case Nil then show ?thesis by (metis append_Nil2 pfx c1 same_prefixeq_nil) |
25299 | 158 |
next |
159 |
case (Cons x xs) |
|
160 |
show ?thesis |
|
161 |
proof (cases "x = a") |
|
25355 | 162 |
case True |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
163 |
have "\<not> prefixeq as xs" using pfx c Cons True by simp |
25355 | 164 |
with c Cons True show ?thesis by (rule c2) |
165 |
next |
|
166 |
case False |
|
167 |
with c Cons show ?thesis by (rule c3) |
|
25299 | 168 |
qed |
169 |
qed |
|
170 |
qed |
|
171 |
||
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
172 |
lemma not_prefixeq_induct [consumes 1, case_names Nil Neq Eq]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
173 |
assumes np: "\<not> prefixeq ps ls" |
25356 | 174 |
and base: "\<And>x xs. P (x#xs) []" |
175 |
and r1: "\<And>x xs y ys. x \<noteq> y \<Longrightarrow> P (x#xs) (y#ys)" |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
176 |
and r2: "\<And>x xs y ys. \<lbrakk> x = y; \<not> prefixeq xs ys; P xs ys \<rbrakk> \<Longrightarrow> P (x#xs) (y#ys)" |
25356 | 177 |
shows "P ps ls" using np |
25299 | 178 |
proof (induct ls arbitrary: ps) |
25355 | 179 |
case Nil then show ?case |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
180 |
by (auto simp: neq_Nil_conv elim!: not_prefixeq_cases intro!: base) |
25299 | 181 |
next |
25355 | 182 |
case (Cons y ys) |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
183 |
then have npfx: "\<not> prefixeq ps (y # ys)" by simp |
25355 | 184 |
then obtain x xs where pv: "ps = x # xs" |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
185 |
by (rule not_prefixeq_cases) auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
186 |
show ?case by (metis Cons.hyps Cons_prefixeq_Cons npfx pv r1 r2) |
25299 | 187 |
qed |
14300 | 188 |
|
25356 | 189 |
|
10389 | 190 |
subsection {* Parallel lists *} |
191 |
||
19086 | 192 |
definition |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21305
diff
changeset
|
193 |
parallel :: "'a list => 'a list => bool" (infixl "\<parallel>" 50) where |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
194 |
"(xs \<parallel> ys) = (\<not> prefixeq xs ys \<and> \<not> prefixeq ys xs)" |
10389 | 195 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
196 |
lemma parallelI [intro]: "\<not> prefixeq xs ys ==> \<not> prefixeq ys xs ==> xs \<parallel> ys" |
25692 | 197 |
unfolding parallel_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
198 |
|
10389 | 199 |
lemma parallelE [elim]: |
25692 | 200 |
assumes "xs \<parallel> ys" |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
201 |
obtains "\<not> prefixeq xs ys \<and> \<not> prefixeq ys xs" |
25692 | 202 |
using assms unfolding parallel_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
203 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
204 |
theorem prefixeq_cases: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
205 |
obtains "prefixeq xs ys" | "prefix ys xs" | "xs \<parallel> ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
206 |
unfolding parallel_def prefix_def by blast |
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
207 |
|
10389 | 208 |
theorem parallel_decomp: |
209 |
"xs \<parallel> ys ==> \<exists>as b bs c cs. b \<noteq> c \<and> xs = as @ b # bs \<and> ys = as @ c # cs" |
|
10408 | 210 |
proof (induct xs rule: rev_induct) |
11987 | 211 |
case Nil |
23254 | 212 |
then have False by auto |
213 |
then show ?case .. |
|
10408 | 214 |
next |
11987 | 215 |
case (snoc x xs) |
216 |
show ?case |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
217 |
proof (rule prefixeq_cases) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
218 |
assume le: "prefixeq xs ys" |
10408 | 219 |
then obtain ys' where ys: "ys = xs @ ys'" .. |
220 |
show ?thesis |
|
221 |
proof (cases ys') |
|
25564 | 222 |
assume "ys' = []" |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
223 |
then show ?thesis by (metis append_Nil2 parallelE prefixeqI snoc.prems ys) |
10389 | 224 |
next |
10408 | 225 |
fix c cs assume ys': "ys' = c # cs" |
25692 | 226 |
then show ?thesis |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
227 |
by (metis Cons_eq_appendI eq_Nil_appendI parallelE prefixeqI |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
228 |
same_prefixeq_prefixeq snoc.prems ys) |
10389 | 229 |
qed |
10408 | 230 |
next |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
231 |
assume "prefix ys xs" then have "prefixeq ys (xs @ [x])" by (simp add: prefix_def) |
11987 | 232 |
with snoc have False by blast |
23254 | 233 |
then show ?thesis .. |
10408 | 234 |
next |
235 |
assume "xs \<parallel> ys" |
|
11987 | 236 |
with snoc obtain as b bs c cs where neq: "(b::'a) \<noteq> c" |
10408 | 237 |
and xs: "xs = as @ b # bs" and ys: "ys = as @ c # cs" |
238 |
by blast |
|
239 |
from xs have "xs @ [x] = as @ b # (bs @ [x])" by simp |
|
240 |
with neq ys show ?thesis by blast |
|
10389 | 241 |
qed |
242 |
qed |
|
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
243 |
|
25564 | 244 |
lemma parallel_append: "a \<parallel> b \<Longrightarrow> a @ c \<parallel> b @ d" |
25692 | 245 |
apply (rule parallelI) |
246 |
apply (erule parallelE, erule conjE, |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
247 |
induct rule: not_prefixeq_induct, simp+)+ |
25692 | 248 |
done |
25299 | 249 |
|
25692 | 250 |
lemma parallel_appendI: "xs \<parallel> ys \<Longrightarrow> x = xs @ xs' \<Longrightarrow> y = ys @ ys' \<Longrightarrow> x \<parallel> y" |
251 |
by (simp add: parallel_append) |
|
25299 | 252 |
|
25692 | 253 |
lemma parallel_commute: "a \<parallel> b \<longleftrightarrow> b \<parallel> a" |
254 |
unfolding parallel_def by auto |
|
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
255 |
|
25356 | 256 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
257 |
subsection {* Suffix order on lists *} |
17201 | 258 |
|
19086 | 259 |
definition |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
260 |
suffixeq :: "'a list => 'a list => bool" where |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
261 |
"suffixeq xs ys = (\<exists>zs. ys = zs @ xs)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
262 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
263 |
definition suffix :: "'a list \<Rightarrow> 'a list \<Rightarrow> bool" where |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
264 |
"suffix xs ys \<equiv> \<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
|
265 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
266 |
lemma suffix_imp_suffixeq: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
267 |
"suffix xs ys \<Longrightarrow> suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
268 |
by (auto simp: suffixeq_def suffix_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
269 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
270 |
lemma suffixeqI [intro?]: "ys = zs @ xs ==> suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
271 |
unfolding suffixeq_def by blast |
21305 | 272 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
273 |
lemma suffixeqE [elim?]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
274 |
assumes "suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
275 |
obtains zs where "ys = zs @ xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
276 |
using assms unfolding suffixeq_def by blast |
21305 | 277 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
278 |
lemma suffixeq_refl [iff]: "suffixeq xs xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
279 |
by (auto simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
280 |
lemma suffix_trans: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
281 |
"suffix xs ys \<Longrightarrow> suffix ys zs \<Longrightarrow> suffix xs zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
282 |
by (auto simp: suffix_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
283 |
lemma suffixeq_trans: "\<lbrakk>suffixeq xs ys; suffixeq ys zs\<rbrakk> \<Longrightarrow> suffixeq xs zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
284 |
by (auto simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
285 |
lemma suffixeq_antisym: "\<lbrakk>suffixeq xs ys; suffixeq ys xs\<rbrakk> \<Longrightarrow> xs = ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
286 |
by (auto simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
287 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
288 |
lemma suffixeq_tl [simp]: "suffixeq (tl xs) xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
289 |
by (induct xs) (auto simp: suffixeq_def) |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
290 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
291 |
lemma suffix_tl [simp]: "xs \<noteq> [] \<Longrightarrow> suffix (tl xs) xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
292 |
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
|
293 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
294 |
lemma Nil_suffixeq [iff]: "suffixeq [] xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
295 |
by (simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
296 |
lemma suffixeq_Nil [simp]: "(suffixeq xs []) = (xs = [])" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
297 |
by (auto simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
298 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
299 |
lemma suffixeq_ConsI: "suffixeq xs ys \<Longrightarrow> suffixeq xs (y#ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
300 |
by (auto simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
301 |
lemma suffixeq_ConsD: "suffixeq (x#xs) ys \<Longrightarrow> suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
302 |
by (auto simp add: suffixeq_def) |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
303 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
304 |
lemma suffixeq_appendI: "suffixeq xs ys \<Longrightarrow> suffixeq xs (zs @ ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
305 |
by (auto simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
306 |
lemma suffixeq_appendD: "suffixeq (zs @ xs) ys \<Longrightarrow> suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
307 |
by (auto simp add: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
308 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
309 |
lemma suffix_set_subset: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
310 |
"suffix xs ys \<Longrightarrow> set xs \<subseteq> set ys" by (auto simp: suffix_def) |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
311 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
312 |
lemma suffixeq_set_subset: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
313 |
"suffixeq xs ys \<Longrightarrow> set xs \<subseteq> set ys" by (auto simp: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
314 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
315 |
lemma suffixeq_ConsD2: "suffixeq (x#xs) (y#ys) ==> suffixeq xs ys" |
21305 | 316 |
proof - |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
317 |
assume "suffixeq (x#xs) (y#ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
318 |
then obtain zs where "y#ys = zs @ x#xs" .. |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
319 |
then show ?thesis |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
320 |
by (induct zs) (auto intro!: suffixeq_appendI suffixeq_ConsI) |
21305 | 321 |
qed |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
322 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
323 |
lemma suffixeq_to_prefixeq [code]: "suffixeq xs ys \<longleftrightarrow> prefixeq (rev xs) (rev ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
324 |
proof |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
325 |
assume "suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
326 |
then obtain zs where "ys = zs @ xs" .. |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
327 |
then have "rev ys = rev xs @ rev zs" by simp |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
328 |
then show "prefixeq (rev xs) (rev ys)" .. |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
329 |
next |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
330 |
assume "prefixeq (rev xs) (rev ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
331 |
then obtain zs where "rev ys = rev xs @ zs" .. |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
332 |
then have "rev (rev ys) = rev zs @ rev (rev xs)" by simp |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
333 |
then have "ys = rev zs @ xs" by simp |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
334 |
then show "suffixeq xs ys" .. |
21305 | 335 |
qed |
14538
1d9d75a8efae
removed o2l and fold_rel; moved postfix to Library/List_Prefix.thy
oheimb
parents:
14300
diff
changeset
|
336 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
337 |
lemma distinct_suffixeq: "distinct ys \<Longrightarrow> suffixeq xs ys \<Longrightarrow> distinct xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
338 |
by (clarsimp elim!: suffixeqE) |
17201 | 339 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
340 |
lemma suffixeq_map: "suffixeq xs ys \<Longrightarrow> suffixeq (map f xs) (map f ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
341 |
by (auto elim!: suffixeqE intro: suffixeqI) |
25299 | 342 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
343 |
lemma suffixeq_drop: "suffixeq (drop n as) as" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
344 |
unfolding suffixeq_def |
25692 | 345 |
apply (rule exI [where x = "take n as"]) |
346 |
apply simp |
|
347 |
done |
|
25299 | 348 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
349 |
lemma suffixeq_take: "suffixeq xs ys \<Longrightarrow> ys = take (length ys - length xs) ys @ xs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
350 |
by (clarsimp elim!: suffixeqE) |
25299 | 351 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
352 |
lemma suffixeq_suffix_reflclp_conv: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
353 |
"suffixeq = suffix\<^sup>=\<^sup>=" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
354 |
proof (intro ext iffI) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
355 |
fix xs ys :: "'a list" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
356 |
assume "suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
357 |
show "suffix\<^sup>=\<^sup>= xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
358 |
proof |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
359 |
assume "xs \<noteq> ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
360 |
with `suffixeq xs ys` show "suffix xs ys" by (auto simp: suffixeq_def suffix_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
361 |
qed |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
362 |
next |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
363 |
fix xs ys :: "'a list" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
364 |
assume "suffix\<^sup>=\<^sup>= xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
365 |
thus "suffixeq xs ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
366 |
proof |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
367 |
assume "suffix xs ys" thus "suffixeq xs ys" by (rule suffix_imp_suffixeq) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
368 |
next |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
369 |
assume "xs = ys" thus "suffixeq xs ys" by (auto simp: suffixeq_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
370 |
qed |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
371 |
qed |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
372 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
373 |
lemma parallelD1: "x \<parallel> y \<Longrightarrow> \<not> prefixeq x y" |
25692 | 374 |
by blast |
25299 | 375 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
376 |
lemma parallelD2: "x \<parallel> y \<Longrightarrow> \<not> prefixeq y x" |
25692 | 377 |
by blast |
25355 | 378 |
|
379 |
lemma parallel_Nil1 [simp]: "\<not> x \<parallel> []" |
|
25692 | 380 |
unfolding parallel_def by simp |
25355 | 381 |
|
25299 | 382 |
lemma parallel_Nil2 [simp]: "\<not> [] \<parallel> x" |
25692 | 383 |
unfolding parallel_def by simp |
25299 | 384 |
|
25564 | 385 |
lemma Cons_parallelI1: "a \<noteq> b \<Longrightarrow> a # as \<parallel> b # bs" |
25692 | 386 |
by auto |
25299 | 387 |
|
25564 | 388 |
lemma Cons_parallelI2: "\<lbrakk> a = b; as \<parallel> bs \<rbrakk> \<Longrightarrow> a # as \<parallel> b # bs" |
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
389 |
by (metis Cons_prefixeq_Cons parallelE parallelI) |
25665 | 390 |
|
25299 | 391 |
lemma not_equal_is_parallel: |
392 |
assumes neq: "xs \<noteq> ys" |
|
25356 | 393 |
and len: "length xs = length ys" |
394 |
shows "xs \<parallel> ys" |
|
25299 | 395 |
using len neq |
25355 | 396 |
proof (induct rule: list_induct2) |
26445 | 397 |
case Nil |
25356 | 398 |
then show ?case by simp |
25299 | 399 |
next |
26445 | 400 |
case (Cons a as b bs) |
25355 | 401 |
have ih: "as \<noteq> bs \<Longrightarrow> as \<parallel> bs" by fact |
25299 | 402 |
show ?case |
403 |
proof (cases "a = b") |
|
25355 | 404 |
case True |
26445 | 405 |
then have "as \<noteq> bs" using Cons by simp |
25355 | 406 |
then show ?thesis by (rule Cons_parallelI2 [OF True ih]) |
25299 | 407 |
next |
408 |
case False |
|
25355 | 409 |
then show ?thesis by (rule Cons_parallelI1) |
25299 | 410 |
qed |
411 |
qed |
|
22178 | 412 |
|
49083
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
413 |
lemma suffix_reflclp_conv: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
414 |
"suffix\<^sup>=\<^sup>= = suffixeq" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
415 |
by (intro ext) (auto simp: suffixeq_def suffix_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
416 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
417 |
lemma suffix_lists: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
418 |
"suffix xs ys \<Longrightarrow> ys \<in> lists A \<Longrightarrow> xs \<in> lists A" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
419 |
unfolding suffix_def by auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
420 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
421 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
422 |
subsection {* Embedding on lists *} |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
423 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
424 |
inductive |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
425 |
emb :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> 'a list \<Rightarrow> 'a list \<Rightarrow> bool" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
426 |
for P :: "('a \<Rightarrow> 'a \<Rightarrow> bool)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
427 |
where |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
428 |
emb_Nil [intro, simp]: "emb P [] ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
429 |
| emb_Cons [intro] : "emb P xs ys \<Longrightarrow> emb P xs (y#ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
430 |
| emb_Cons2 [intro]: "P x y \<Longrightarrow> emb P xs ys \<Longrightarrow> emb P (x#xs) (y#ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
431 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
432 |
lemma emb_Nil2 [simp]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
433 |
assumes "emb P xs []" shows "xs = []" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
434 |
using assms by (cases rule: emb.cases) auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
435 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
436 |
lemma emb_append2 [intro]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
437 |
"emb P xs ys \<Longrightarrow> emb P xs (zs @ ys)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
438 |
by (induct zs) auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
439 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
440 |
lemma emb_prefix [intro]: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
441 |
assumes "emb P xs ys" shows "emb P xs (ys @ zs)" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
442 |
using assms |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
443 |
by (induct arbitrary: zs) auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
444 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
445 |
lemma emb_ConsD: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
446 |
assumes "emb P (x#xs) ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
447 |
shows "\<exists>us v vs. ys = us @ v # vs \<and> P x v \<and> emb P xs vs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
448 |
using assms |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
449 |
proof (induct x\<equiv>"x#xs" y\<equiv>"ys" arbitrary: x xs ys) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
450 |
case emb_Cons thus ?case by (metis append_Cons) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
451 |
next |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
452 |
case (emb_Cons2 x y xs ys) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
453 |
thus ?case by (cases xs) (auto, blast+) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
454 |
qed |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
455 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
456 |
lemma emb_appendD: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
457 |
assumes "emb P (xs @ ys) zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
458 |
shows "\<exists>us vs. zs = us @ vs \<and> emb P xs us \<and> emb P ys vs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
459 |
using assms |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
460 |
proof (induction xs arbitrary: ys zs) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
461 |
case Nil thus ?case by auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
462 |
next |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
463 |
case (Cons x xs) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
464 |
then obtain us v vs where "zs = us @ v # vs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
465 |
and "P x v" and "emb P (xs @ ys) vs" by (auto dest: emb_ConsD) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
466 |
with Cons show ?case by (metis append_Cons append_assoc emb_Cons2 emb_append2) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
467 |
qed |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
468 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
469 |
lemma emb_suffix: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
470 |
assumes "emb P xs ys" and "suffix ys zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
471 |
shows "emb P xs zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
472 |
using assms(2) and emb_append2 [OF assms(1)] by (auto simp: suffix_def) |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
473 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
474 |
lemma emb_suffixeq: |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
475 |
assumes "emb P xs ys" and "suffixeq ys zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
476 |
shows "emb P xs zs" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
477 |
using assms and emb_suffix unfolding suffixeq_suffix_reflclp_conv by auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
478 |
|
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
479 |
lemma emb_length: "emb P xs ys \<Longrightarrow> length xs \<le> length ys" |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
480 |
by (induct rule: emb.induct) auto |
01081bca31b6
dropped ord and bot instance for list prefixes (use locale interpretation instead, which allows users to decide what order to use on lists)
Christian Sternagel
parents:
45236
diff
changeset
|
481 |
|
10330
4362e906b745
"List prefixes" library theory (replaces old Lex/Prefix);
wenzelm
parents:
diff
changeset
|
482 |
end |