author | wenzelm |
Fri, 05 Jan 2007 14:30:07 +0100 | |
changeset 22013 | a3519c0c2d8f |
parent 19769 | c40ce2de2020 |
child 22282 | 71b4aefad227 |
permissions | -rw-r--r-- |
19203 | 1 |
(* Title: HOL/ZF/LProd.thy |
2 |
ID: $Id$ |
|
3 |
Author: Steven Obua |
|
4 |
||
5 |
Introduces the lprod relation. |
|
6 |
See "Partizan Games in Isabelle/HOLZF", available from http://www4.in.tum.de/~obua/partizan |
|
7 |
*) |
|
8 |
||
9 |
theory LProd |
|
10 |
imports Multiset |
|
11 |
begin |
|
12 |
||
13 |
consts |
|
14 |
lprod :: "('a * 'a) set \<Rightarrow> ('a list * 'a list) set" |
|
15 |
||
16 |
inductive "lprod R" |
|
17 |
intros |
|
18 |
lprod_single[intro!]: "(a, b) \<in> R \<Longrightarrow> ([a], [b]) \<in> lprod R" |
|
19 |
lprod_list[intro!]: "(ah@at, bh@bt) \<in> lprod R \<Longrightarrow> (a,b) \<in> R \<or> a = b \<Longrightarrow> (ah@a#at, bh@b#bt) \<in> lprod R" |
|
20 |
||
21 |
lemma "(as,bs) \<in> lprod R \<Longrightarrow> length as = length bs" |
|
22 |
apply (induct as bs rule: lprod.induct) |
|
23 |
apply auto |
|
24 |
done |
|
25 |
||
26 |
lemma "(as, bs) \<in> lprod R \<Longrightarrow> 1 \<le> length as \<and> 1 \<le> length bs" |
|
27 |
apply (induct as bs rule: lprod.induct) |
|
28 |
apply auto |
|
29 |
done |
|
30 |
||
31 |
lemma lprod_subset_elem: "(as, bs) \<in> lprod S \<Longrightarrow> S \<subseteq> R \<Longrightarrow> (as, bs) \<in> lprod R" |
|
32 |
apply (induct as bs rule: lprod.induct) |
|
33 |
apply (auto) |
|
34 |
done |
|
35 |
||
36 |
lemma lprod_subset: "S \<subseteq> R \<Longrightarrow> lprod S \<subseteq> lprod R" |
|
37 |
by (auto intro: lprod_subset_elem) |
|
38 |
||
39 |
lemma lprod_implies_mult: "(as, bs) \<in> lprod R \<Longrightarrow> trans R \<Longrightarrow> (multiset_of as, multiset_of bs) \<in> mult R" |
|
40 |
proof (induct as bs rule: lprod.induct) |
|
41 |
case (lprod_single a b) |
|
42 |
note step = one_step_implies_mult[ |
|
43 |
where r=R and I="{#}" and K="{#a#}" and J="{#b#}", simplified] |
|
44 |
show ?case by (auto intro: lprod_single step) |
|
45 |
next |
|
46 |
case (lprod_list a ah at b bh bt) |
|
47 |
from prems have transR: "trans R" by auto |
|
48 |
have as: "multiset_of (ah @ a # at) = multiset_of (ah @ at) + {#a#}" (is "_ = ?ma + _") |
|
49 |
by (simp add: ring_eq_simps) |
|
50 |
have bs: "multiset_of (bh @ b # bt) = multiset_of (bh @ bt) + {#b#}" (is "_ = ?mb + _") |
|
51 |
by (simp add: ring_eq_simps) |
|
52 |
from prems have "(?ma, ?mb) \<in> mult R" |
|
53 |
by auto |
|
54 |
with mult_implies_one_step[OF transR] have |
|
55 |
"\<exists>I J K. ?mb = I + J \<and> ?ma = I + K \<and> J \<noteq> {#} \<and> (\<forall>k\<in>set_of K. \<exists>j\<in>set_of J. (k, j) \<in> R)" |
|
56 |
by blast |
|
57 |
then obtain I J K where |
|
58 |
decomposed: "?mb = I + J \<and> ?ma = I + K \<and> J \<noteq> {#} \<and> (\<forall>k\<in>set_of K. \<exists>j\<in>set_of J. (k, j) \<in> R)" |
|
59 |
by blast |
|
60 |
show ?case |
|
61 |
proof (cases "a = b") |
|
62 |
case True |
|
63 |
have "((I + {#b#}) + K, (I + {#b#}) + J) \<in> mult R" |
|
64 |
apply (rule one_step_implies_mult[OF transR]) |
|
65 |
apply (auto simp add: decomposed) |
|
66 |
done |
|
67 |
then show ?thesis |
|
68 |
apply (simp only: as bs) |
|
69 |
apply (simp only: decomposed True) |
|
70 |
apply (simp add: ring_eq_simps) |
|
71 |
done |
|
72 |
next |
|
73 |
case False |
|
74 |
from False lprod_list have False: "(a, b) \<in> R" by blast |
|
75 |
have "(I + (K + {#a#}), I + (J + {#b#})) \<in> mult R" |
|
76 |
apply (rule one_step_implies_mult[OF transR]) |
|
77 |
apply (auto simp add: False decomposed) |
|
78 |
done |
|
79 |
then show ?thesis |
|
80 |
apply (simp only: as bs) |
|
81 |
apply (simp only: decomposed) |
|
82 |
apply (simp add: ring_eq_simps) |
|
83 |
done |
|
84 |
qed |
|
85 |
qed |
|
86 |
||
87 |
lemma wf_lprod[recdef_wf,simp,intro]: |
|
88 |
assumes wf_R: "wf R" |
|
89 |
shows "wf (lprod R)" |
|
90 |
proof - |
|
91 |
have subset: "lprod (R^+) \<subseteq> inv_image (mult (R^+)) multiset_of" |
|
19769
c40ce2de2020
Added [simp]-lemmas "in_inv_image" and "in_lex_prod" in the spirit of "in_measure".
krauss
parents:
19203
diff
changeset
|
92 |
by (auto simp add: lprod_implies_mult trans_trancl) |
19203 | 93 |
note lprodtrancl = wf_subset[OF wf_inv_image[where r="mult (R^+)" and f="multiset_of", |
94 |
OF wf_mult[OF wf_trancl[OF wf_R]]], OF subset] |
|
95 |
note lprod = wf_subset[OF lprodtrancl, where p="lprod R", OF lprod_subset, simplified] |
|
96 |
show ?thesis by (auto intro: lprod) |
|
97 |
qed |
|
98 |
||
99 |
constdefs |
|
100 |
gprod_2_2 :: "('a * 'a) set \<Rightarrow> (('a * 'a) * ('a * 'a)) set" |
|
101 |
"gprod_2_2 R \<equiv> { ((a,b), (c,d)) . (a = c \<and> (b,d) \<in> R) \<or> (b = d \<and> (a,c) \<in> R) }" |
|
102 |
gprod_2_1 :: "('a * 'a) set \<Rightarrow> (('a * 'a) * ('a * 'a)) set" |
|
103 |
"gprod_2_1 R \<equiv> { ((a,b), (c,d)) . (a = d \<and> (b,c) \<in> R) \<or> (b = c \<and> (a,d) \<in> R) }" |
|
104 |
||
105 |
lemma lprod_2_3: "(a, b) \<in> R \<Longrightarrow> ([a, c], [b, c]) \<in> lprod R" |
|
106 |
by (auto intro: lprod_list[where a=c and b=c and |
|
107 |
ah = "[a]" and at = "[]" and bh="[b]" and bt="[]", simplified]) |
|
108 |
||
109 |
lemma lprod_2_4: "(a, b) \<in> R \<Longrightarrow> ([c, a], [c, b]) \<in> lprod R" |
|
110 |
by (auto intro: lprod_list[where a=c and b=c and |
|
111 |
ah = "[]" and at = "[a]" and bh="[]" and bt="[b]", simplified]) |
|
112 |
||
113 |
lemma lprod_2_1: "(a, b) \<in> R \<Longrightarrow> ([c, a], [b, c]) \<in> lprod R" |
|
114 |
by (auto intro: lprod_list[where a=c and b=c and |
|
115 |
ah = "[]" and at = "[a]" and bh="[b]" and bt="[]", simplified]) |
|
116 |
||
117 |
lemma lprod_2_2: "(a, b) \<in> R \<Longrightarrow> ([a, c], [c, b]) \<in> lprod R" |
|
118 |
by (auto intro: lprod_list[where a=c and b=c and |
|
119 |
ah = "[a]" and at = "[]" and bh="[]" and bt="[b]", simplified]) |
|
120 |
||
121 |
lemma [recdef_wf, simp, intro]: |
|
122 |
assumes wfR: "wf R" shows "wf (gprod_2_1 R)" |
|
123 |
proof - |
|
124 |
have "gprod_2_1 R \<subseteq> inv_image (lprod R) (\<lambda> (a,b). [a,b])" |
|
19769
c40ce2de2020
Added [simp]-lemmas "in_inv_image" and "in_lex_prod" in the spirit of "in_measure".
krauss
parents:
19203
diff
changeset
|
125 |
by (auto simp add: gprod_2_1_def lprod_2_1 lprod_2_2) |
19203 | 126 |
with wfR show ?thesis |
127 |
by (rule_tac wf_subset, auto) |
|
128 |
qed |
|
129 |
||
130 |
lemma [recdef_wf, simp, intro]: |
|
131 |
assumes wfR: "wf R" shows "wf (gprod_2_2 R)" |
|
132 |
proof - |
|
133 |
have "gprod_2_2 R \<subseteq> inv_image (lprod R) (\<lambda> (a,b). [a,b])" |
|
19769
c40ce2de2020
Added [simp]-lemmas "in_inv_image" and "in_lex_prod" in the spirit of "in_measure".
krauss
parents:
19203
diff
changeset
|
134 |
by (auto simp add: gprod_2_2_def lprod_2_3 lprod_2_4) |
19203 | 135 |
with wfR show ?thesis |
136 |
by (rule_tac wf_subset, auto) |
|
137 |
qed |
|
138 |
||
139 |
lemma lprod_3_1: assumes "(x', x) \<in> R" shows "([y, z, x'], [x, y, z]) \<in> lprod R" |
|
140 |
apply (rule lprod_list[where a="y" and b="y" and ah="[]" and at="[z,x']" and bh="[x]" and bt="[z]", simplified]) |
|
141 |
apply (auto simp add: lprod_2_1 prems) |
|
142 |
done |
|
143 |
||
144 |
lemma lprod_3_2: assumes "(z',z) \<in> R" shows "([z', x, y], [x,y,z]) \<in> lprod R" |
|
145 |
apply (rule lprod_list[where a="y" and b="y" and ah="[z',x]" and at="[]" and bh="[x]" and bt="[z]", simplified]) |
|
146 |
apply (auto simp add: lprod_2_2 prems) |
|
147 |
done |
|
148 |
||
149 |
lemma lprod_3_3: assumes xr: "(xr, x) \<in> R" shows "([xr, y, z], [x, y, z]) \<in> lprod R" |
|
150 |
apply (rule lprod_list[where a="y" and b="y" and ah="[xr]" and at="[z]" and bh="[x]" and bt="[z]", simplified]) |
|
151 |
apply (simp add: xr lprod_2_3) |
|
152 |
done |
|
153 |
||
154 |
lemma lprod_3_4: assumes yr: "(yr, y) \<in> R" shows "([x, yr, z], [x, y, z]) \<in> lprod R" |
|
155 |
apply (rule lprod_list[where a="x" and b="x" and ah="[]" and at="[yr,z]" and bh="[]" and bt="[y,z]", simplified]) |
|
156 |
apply (simp add: yr lprod_2_3) |
|
157 |
done |
|
158 |
||
159 |
lemma lprod_3_5: assumes zr: "(zr, z) \<in> R" shows "([x, y, zr], [x, y, z]) \<in> lprod R" |
|
160 |
apply (rule lprod_list[where a="x" and b="x" and ah="[]" and at="[y,zr]" and bh="[]" and bt="[y,z]", simplified]) |
|
161 |
apply (simp add: zr lprod_2_4) |
|
162 |
done |
|
163 |
||
164 |
lemma lprod_3_6: assumes y': "(y', y) \<in> R" shows "([x, z, y'], [x, y, z]) \<in> lprod R" |
|
165 |
apply (rule lprod_list[where a="z" and b="z" and ah="[x]" and at="[y']" and bh="[x,y]" and bt="[]", simplified]) |
|
166 |
apply (simp add: y' lprod_2_4) |
|
167 |
done |
|
168 |
||
169 |
lemma lprod_3_7: assumes z': "(z',z) \<in> R" shows "([x, z', y], [x, y, z]) \<in> lprod R" |
|
170 |
apply (rule lprod_list[where a="y" and b="y" and ah="[x, z']" and at="[]" and bh="[x]" and bt="[z]", simplified]) |
|
171 |
apply (simp add: z' lprod_2_4) |
|
172 |
done |
|
173 |
||
174 |
constdefs |
|
175 |
perm :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a set \<Rightarrow> bool" |
|
176 |
"perm f A \<equiv> inj_on f A \<and> f ` A = A" |
|
177 |
||
178 |
lemma "((as,bs) \<in> lprod R) = |
|
179 |
(\<exists> f. perm f {0 ..< (length as)} \<and> |
|
180 |
(\<forall> j. j < length as \<longrightarrow> ((nth as j, nth bs (f j)) \<in> R \<or> (nth as j = nth bs (f j)))) \<and> |
|
181 |
(\<exists> i. i < length as \<and> (nth as i, nth bs (f i)) \<in> R))" |
|
182 |
oops |
|
183 |
||
184 |
lemma "trans R \<Longrightarrow> (ah@a#at, bh@b#bt) \<in> lprod R \<Longrightarrow> (b, a) \<in> R \<or> a = b \<Longrightarrow> (ah@at, bh@bt) \<in> lprod R" |
|
185 |
oops |
|
186 |
||
187 |
||
188 |
||
189 |
end |