author | haftmann |
Wed, 14 Jul 2010 14:20:47 +0200 | |
changeset 37819 | 000049335247 |
parent 36862 | 952b2b102a0a |
child 39126 | ee117c5b3b75 |
permissions | -rw-r--r-- |
5261 | 1 |
(* Title: HOL/Lambda/ListOrder.thy |
2 |
Author: Tobias Nipkow |
|
3 |
Copyright 1998 TU Muenchen |
|
4 |
*) |
|
5 |
||
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
6 |
header {* Lifting an order to lists of elements *} |
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
7 |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
19086
diff
changeset
|
8 |
theory ListOrder imports Main begin |
5261 | 9 |
|
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
10 |
text {* |
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
11 |
Lifting an order to lists of elements, relating exactly one |
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
12 |
element. |
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
13 |
*} |
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
14 |
|
19086 | 15 |
definition |
22270 | 16 |
step1 :: "('a => 'a => bool) => 'a list => 'a list => bool" where |
19086 | 17 |
"step1 r = |
22270 | 18 |
(\<lambda>ys xs. \<exists>us z z' vs. xs = us @ z # vs \<and> r z' z \<and> ys = |
19 |
us @ z' # vs)" |
|
9771 | 20 |
|
21 |
||
22270 | 22 |
lemma step1_converse [simp]: "step1 (r^--1) = (step1 r)^--1" |
23 |
apply (unfold step1_def) |
|
24 |
apply (blast intro!: order_antisym) |
|
25 |
done |
|
26 |
||
27 |
lemma in_step1_converse [iff]: "(step1 (r^--1) x y) = ((step1 r)^--1 x y)" |
|
28 |
apply auto |
|
29 |
done |
|
30 |
||
31 |
lemma not_Nil_step1 [iff]: "\<not> step1 r [] xs" |
|
9771 | 32 |
apply (unfold step1_def) |
33 |
apply blast |
|
34 |
done |
|
35 |
||
22270 | 36 |
lemma not_step1_Nil [iff]: "\<not> step1 r xs []" |
9771 | 37 |
apply (unfold step1_def) |
38 |
apply blast |
|
39 |
done |
|
40 |
||
41 |
lemma Cons_step1_Cons [iff]: |
|
22270 | 42 |
"(step1 r (y # ys) (x # xs)) = |
43 |
(r y x \<and> xs = ys \<or> x = y \<and> step1 r ys xs)" |
|
9771 | 44 |
apply (unfold step1_def) |
45 |
apply (rule iffI) |
|
46 |
apply (erule exE) |
|
47 |
apply (rename_tac ts) |
|
48 |
apply (case_tac ts) |
|
13601 | 49 |
apply fastsimp |
9771 | 50 |
apply force |
51 |
apply (erule disjE) |
|
52 |
apply blast |
|
53 |
apply (blast intro: Cons_eq_appendI) |
|
54 |
done |
|
55 |
||
56 |
lemma append_step1I: |
|
22270 | 57 |
"step1 r ys xs \<and> vs = us \<or> ys = xs \<and> step1 r vs us |
58 |
==> step1 r (ys @ vs) (xs @ us)" |
|
9771 | 59 |
apply (unfold step1_def) |
60 |
apply auto |
|
61 |
apply blast |
|
62 |
apply (blast intro: append_eq_appendI) |
|
63 |
done |
|
64 |
||
18257 | 65 |
lemma Cons_step1E [elim!]: |
22270 | 66 |
assumes "step1 r ys (x # xs)" |
67 |
and "!!y. ys = y # xs \<Longrightarrow> r y x \<Longrightarrow> R" |
|
68 |
and "!!zs. ys = x # zs \<Longrightarrow> step1 r zs xs \<Longrightarrow> R" |
|
18257 | 69 |
shows R |
23464 | 70 |
using assms |
18257 | 71 |
apply (cases ys) |
9771 | 72 |
apply (simp add: step1_def) |
73 |
apply blast |
|
74 |
done |
|
75 |
||
76 |
lemma Snoc_step1_SnocD: |
|
22270 | 77 |
"step1 r (ys @ [y]) (xs @ [x]) |
78 |
==> (step1 r ys xs \<and> y = x \<or> ys = xs \<and> r y x)" |
|
9771 | 79 |
apply (unfold step1_def) |
80 |
apply (clarify del: disjCI) |
|
81 |
apply (rename_tac vs) |
|
82 |
apply (rule_tac xs = vs in rev_exhaust) |
|
83 |
apply force |
|
84 |
apply simp |
|
85 |
apply blast |
|
86 |
done |
|
87 |
||
18241 | 88 |
lemma Cons_acc_step1I [intro!]: |
23750 | 89 |
"accp r x ==> accp (step1 r) xs \<Longrightarrow> accp (step1 r) (x # xs)" |
90 |
apply (induct arbitrary: xs set: accp) |
|
9771 | 91 |
apply (erule thin_rl) |
23750 | 92 |
apply (erule accp_induct) |
93 |
apply (rule accp.accI) |
|
9771 | 94 |
apply blast |
95 |
done |
|
96 |
||
23750 | 97 |
lemma lists_accD: "listsp (accp r) xs ==> accp (step1 r) xs" |
22270 | 98 |
apply (induct set: listsp) |
23750 | 99 |
apply (rule accp.accI) |
9771 | 100 |
apply simp |
23750 | 101 |
apply (rule accp.accI) |
102 |
apply (fast dest: accp_downward) |
|
9771 | 103 |
done |
104 |
||
9811
39ffdb8cab03
HOL/Lambda: converted into new-style theory and document;
wenzelm
parents:
9771
diff
changeset
|
105 |
lemma ex_step1I: |
22270 | 106 |
"[| x \<in> set xs; r y x |] |
107 |
==> \<exists>ys. step1 r ys xs \<and> y \<in> set ys" |
|
9771 | 108 |
apply (unfold step1_def) |
109 |
apply (drule in_set_conv_decomp [THEN iffD1]) |
|
110 |
apply force |
|
111 |
done |
|
112 |
||
23750 | 113 |
lemma lists_accI: "accp (step1 r) xs ==> listsp (accp r) xs" |
114 |
apply (induct set: accp) |
|
9771 | 115 |
apply clarify |
23750 | 116 |
apply (rule accp.accI) |
22270 | 117 |
apply (drule_tac r=r in ex_step1I, assumption) |
9771 | 118 |
apply blast |
119 |
done |
|
5261 | 120 |
|
11639 | 121 |
end |