5261
|
1 |
(* Title: HOL/Lambda/ListOrder.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow
|
|
4 |
Copyright 1998 TU Muenchen
|
|
5 |
|
|
6 |
Lifting an order to lists of elements, relating exactly one element
|
|
7 |
*)
|
|
8 |
|
9771
|
9 |
theory ListOrder = Acc:
|
5261
|
10 |
|
|
11 |
constdefs
|
9771
|
12 |
step1 :: "('a \<times> 'a) set => ('a list \<times> 'a list) set"
|
|
13 |
"step1 r ==
|
|
14 |
{(ys, xs). \<exists>us z z' vs. xs = us @ z # vs \<and> (z', z) \<in> r \<and> ys = us @ z' # vs}"
|
|
15 |
|
|
16 |
|
|
17 |
lemma step1_converse [simp]: "step1 (r^-1) = (step1 r)^-1"
|
|
18 |
apply (unfold step1_def)
|
|
19 |
apply blast
|
|
20 |
done
|
|
21 |
|
|
22 |
lemma in_step1_converse [iff]: "(p \<in> step1 (r^-1)) = (p \<in> (step1 r)^-1)"
|
|
23 |
apply auto
|
|
24 |
done
|
|
25 |
|
|
26 |
lemma not_Nil_step1 [iff]: "([], xs) \<notin> step1 r"
|
|
27 |
apply (unfold step1_def)
|
|
28 |
apply blast
|
|
29 |
done
|
|
30 |
|
|
31 |
lemma not_step1_Nil [iff]: "(xs, []) \<notin> step1 r"
|
|
32 |
apply (unfold step1_def)
|
|
33 |
apply blast
|
|
34 |
done
|
|
35 |
|
|
36 |
lemma Cons_step1_Cons [iff]:
|
|
37 |
"((y # ys, x # xs) \<in> step1 r) = ((y, x) \<in> r \<and> xs = ys \<or> x = y \<and> (ys, xs) \<in> step1 r)"
|
|
38 |
apply (unfold step1_def)
|
|
39 |
apply simp
|
|
40 |
apply (rule iffI)
|
|
41 |
apply (erule exE)
|
|
42 |
apply (rename_tac ts)
|
|
43 |
apply (case_tac ts)
|
|
44 |
apply force
|
|
45 |
apply force
|
|
46 |
apply (erule disjE)
|
|
47 |
apply blast
|
|
48 |
apply (blast intro: Cons_eq_appendI)
|
|
49 |
done
|
|
50 |
|
|
51 |
lemma append_step1I:
|
|
52 |
"(ys, xs) \<in> step1 r \<and> vs = us \<or> ys = xs \<and> (vs, us) \<in> step1 r
|
|
53 |
==> (ys @ vs, xs @ us) : step1 r"
|
|
54 |
apply (unfold step1_def)
|
|
55 |
apply auto
|
|
56 |
apply blast
|
|
57 |
apply (blast intro: append_eq_appendI)
|
|
58 |
done
|
|
59 |
|
|
60 |
lemma Cons_step1E [rulify_prems, elim!]:
|
|
61 |
"[| (ys, x # xs) \<in> step1 r;
|
|
62 |
\<forall>y. ys = y # xs --> (y, x) \<in> r --> R;
|
|
63 |
\<forall>zs. ys = x # zs --> (zs, xs) : step1 r --> R
|
|
64 |
|] ==> R"
|
|
65 |
apply (case_tac ys)
|
|
66 |
apply (simp add: step1_def)
|
|
67 |
apply blast
|
|
68 |
done
|
|
69 |
|
|
70 |
lemma Snoc_step1_SnocD:
|
|
71 |
"(ys @ [y], xs @ [x]) \<in> step1 r
|
|
72 |
==> ((ys, xs) \<in> step1 r \<and> y = x \<or> ys = xs \<and> (y, x) \<in> r)"
|
|
73 |
apply (unfold step1_def)
|
|
74 |
apply simp
|
|
75 |
apply (clarify del: disjCI)
|
|
76 |
apply (rename_tac vs)
|
|
77 |
apply (rule_tac xs = vs in rev_exhaust)
|
|
78 |
apply force
|
|
79 |
apply simp
|
|
80 |
apply blast
|
|
81 |
done
|
|
82 |
|
|
83 |
lemma Cons_acc_step1I [rulify, intro!]:
|
|
84 |
"x \<in> acc r ==> \<forall>xs. xs \<in> acc (step1 r) --> x # xs \<in> acc (step1 r)"
|
|
85 |
apply (erule acc_induct)
|
|
86 |
apply (erule thin_rl)
|
|
87 |
apply clarify
|
|
88 |
apply (erule acc_induct)
|
|
89 |
apply (rule accI)
|
|
90 |
apply blast
|
|
91 |
done
|
|
92 |
|
|
93 |
lemma lists_accD: "xs \<in> lists (acc r) ==> xs \<in> acc (step1 r)"
|
|
94 |
apply (erule lists.induct)
|
|
95 |
apply (rule accI)
|
|
96 |
apply simp
|
|
97 |
apply (rule accI)
|
|
98 |
apply (fast dest: acc_downward)
|
|
99 |
done
|
|
100 |
|
|
101 |
lemma ex_step1I: "[| x \<in> set xs; (y, x) \<in> r |]
|
|
102 |
==> \<exists>ys. (ys, xs) \<in> step1 r \<and> y \<in> set ys"
|
|
103 |
apply (unfold step1_def)
|
|
104 |
apply (drule in_set_conv_decomp [THEN iffD1])
|
|
105 |
apply force
|
|
106 |
done
|
|
107 |
|
|
108 |
lemma lists_accI: "xs \<in> acc (step1 r) ==> xs \<in> lists (acc r)"
|
|
109 |
apply (erule acc_induct)
|
|
110 |
apply clarify
|
|
111 |
apply (rule accI)
|
|
112 |
apply (drule ex_step1I, assumption)
|
|
113 |
apply blast
|
|
114 |
done
|
5261
|
115 |
|
|
116 |
end
|