119 |
129 |
120 |
130 |
121 text {* \medskip Final argument is surprisingly complex *} |
131 text {* \medskip Final argument is surprisingly complex *} |
122 |
132 |
123 theorem gen_mutil_not_tiling: |
133 theorem gen_mutil_not_tiling: |
124 "t \<in> tiling domino ==> |
134 "t \<in> tiling domino ==> |
125 (i + j) mod 2 = 0 ==> (m + n) mod 2 = 0 ==> |
135 (i + j) mod 2 = 0 ==> (m + n) mod 2 = 0 ==> |
126 {(i, j), (m, n)} \<subseteq> t |
136 {(i, j), (m, n)} \<subseteq> t |
127 ==> (t - {(i, j)} - {(m, n)}) \<notin> tiling domino" |
137 ==> (t - {(i,j)} - {(m,n)}) \<notin> tiling domino" |
128 apply (rule notI) |
138 apply (rule notI) |
129 apply (subgoal_tac |
139 apply (subgoal_tac |
130 "card (whites \<inter> (t - {(i, j)} - {(m, n)})) < |
140 "card (whites \<inter> (t - {(i,j)} - {(m,n)})) < |
131 card (blacks \<inter> (t - {(i, j)} - {(m, n)}))") |
141 card (blacks \<inter> (t - {(i,j)} - {(m,n)}))") |
132 apply (force simp only: tiling_domino_0_1) |
142 apply (force simp only: tiling_domino_0_1) |
133 apply (simp add: tiling_domino_0_1 [symmetric]) |
143 apply (simp add: tiling_domino_0_1 [symmetric]) |
134 apply (simp add: coloured_def card_Diff2_less) |
144 apply (simp add: coloured_def card_Diff2_less) |
135 done |
145 done |
136 |
146 |
137 text {* Apply the general theorem to the well-known case *} |
147 text {* Apply the general theorem to the well-known case *} |
138 |
148 |
139 theorem mutil_not_tiling: |
149 theorem mutil_not_tiling: |
140 "t = lessThan (2 * Suc m) \<times> lessThan (2 * Suc n) |
150 "t = {0..< 2 * Suc m} \<times> {0..< 2 * Suc n} |
141 ==> t - {(0, 0)} - {(Suc (2 * m), Suc (2 * n))} \<notin> tiling domino" |
151 ==> t - {(0,0)} - {(Suc(2 * m), Suc(2 * n))} \<notin> tiling domino" |
142 apply (rule gen_mutil_not_tiling) |
152 apply (rule gen_mutil_not_tiling) |
143 apply (blast intro!: dominoes_tile_matrix) |
153 apply (blast intro!: dominoes_tile_matrix) |
144 apply auto |
154 apply auto |
145 done |
155 done |
|
156 |
|
157 |
|
158 subsection{* The Mutilated Chess Board Can be Tiled by Ls *} |
|
159 |
|
160 text{* We remove any square from a chess board of size $2^n \times 2^n$. |
|
161 The result can be tiled by L-shaped tiles. |
|
162 Found in Velleman's \emph{How to Prove it}. |
|
163 |
|
164 The four possible L-shaped tiles are obtained by dropping |
|
165 one of the four squares from $\{(x,y),(x+1,y),(x,y+1),(x+1,y+1)\}$: *} |
|
166 |
|
167 definition "L2 (x::nat) (y::nat) = {(x,y), (x+1,y), (x, y+1)}" |
|
168 definition "L3 (x::nat) (y::nat) = {(x,y), (x+1,y), (x+1, y+1)}" |
|
169 definition "L0 (x::nat) (y::nat) = {(x+1,y), (x,y+1), (x+1, y+1)}" |
|
170 definition "L1 (x::nat) (y::nat) = {(x,y), (x,y+1), (x+1, y+1)}" |
|
171 |
|
172 text{* All tiles: *} |
|
173 |
|
174 definition Ls :: "(nat * nat) set set" where |
|
175 "Ls \<equiv> { L0 x y | x y. True} \<union> { L1 x y | x y. True} \<union> |
|
176 { L2 x y | x y. True} \<union> { L3 x y | x y. True}" |
|
177 |
|
178 lemma LinLs: "L0 i j : Ls & L1 i j : Ls & L2 i j : Ls & L3 i j : Ls" |
|
179 by(fastsimp simp:Ls_def) |
|
180 |
|
181 |
|
182 text{* Square $2^n \times 2^n$ grid, shifted by $i$ and $j$: *} |
|
183 |
|
184 definition "square2 (n::nat) (i::nat) (j::nat) = {i..< 2^n+i} \<times> {j..< 2^n+j}" |
|
185 |
|
186 lemma in_square2[simp]: |
|
187 "(a,b) : square2 n i j \<longleftrightarrow> i\<le>a \<and> a<2^n+i \<and> j\<le>b \<and> b<2^n+j" |
|
188 by(simp add:square2_def) |
|
189 |
|
190 lemma square2_Suc: "square2 (Suc n) i j = |
|
191 square2 n i j \<union> square2 n (2^n + i) j \<union> square2 n i (2^n + j) \<union> |
|
192 square2 n (2^n + i) (2^n + j)" |
|
193 by(auto simp:square2_def) |
|
194 |
|
195 lemma square2_disj: "square2 n i j \<inter> square2 n x y = {} \<longleftrightarrow> |
|
196 (2^n+i \<le> x \<or> 2^n+x \<le> i) \<or> (2^n+j \<le> y \<or> 2^n+y \<le> j)" (is "?A = ?B") |
|
197 proof- |
|
198 { assume ?B hence ?A by(auto simp:square2_def) } |
|
199 moreover |
|
200 { assume "\<not> ?B" |
|
201 hence "(max i x, max j y) : square2 n i j \<inter> square2 n x y" by simp |
|
202 hence "\<not> ?A" by blast } |
|
203 ultimately show ?thesis by blast |
|
204 qed |
|
205 |
|
206 text{* Some specific lemmas: *} |
|
207 |
|
208 lemma pos_pow2: "(0::nat) < 2^(n::nat)" |
|
209 by simp |
|
210 |
|
211 declare nat_zero_less_power_iff[simp del] zero_less_power[simp del] |
|
212 |
|
213 lemma Diff_insert_if: shows |
|
214 "B \<noteq> {} \<Longrightarrow> a:A \<Longrightarrow> A - insert a B = (A-B - {a})" and |
|
215 "B \<noteq> {} \<Longrightarrow> a ~: A \<Longrightarrow> A - insert a B = A-B" |
|
216 by auto |
|
217 |
|
218 lemma DisjI1: "A Int B = {} \<Longrightarrow> (A-X) Int B = {}" |
|
219 by blast |
|
220 lemma DisjI2: "A Int B = {} \<Longrightarrow> A Int (B-X) = {}" |
|
221 by blast |
|
222 |
|
223 text{* The main theorem: *} |
|
224 |
|
225 theorem Ls_can_tile: "i \<le> a \<Longrightarrow> a < 2^n + i \<Longrightarrow> j \<le> b \<Longrightarrow> b < 2^n + j |
|
226 \<Longrightarrow> square2 n i j - {(a,b)} : tiling Ls" |
|
227 proof(induct n arbitrary: a b i j) |
|
228 case 0 thus ?case by (simp add:square2_def) |
|
229 next |
|
230 case (Suc n) note IH = Suc(1) and a = Suc(2-3) and b = Suc(4-5) |
|
231 hence "a<2^n+i \<and> b<2^n+j \<or> |
|
232 2^n+i\<le>a \<and> a<2^(n+1)+i \<and> b<2^n+j \<or> |
|
233 a<2^n+i \<and> 2^n+j\<le>b \<and> b<2^(n+1)+j \<or> |
|
234 2^n+i\<le>a \<and> a<2^(n+1)+i \<and> 2^n+j\<le>b \<and> b<2^(n+1)+j" (is "?A|?B|?C|?D") |
|
235 by simp arith |
|
236 moreover |
|
237 { assume "?A" |
|
238 hence "square2 n i j - {(a,b)} : tiling Ls" using IH a b by auto |
|
239 moreover have "square2 n (2^n+i) j - {(2^n+i,2^n+j - 1)} : tiling Ls" |
|
240 by(rule IH)(insert pos_pow2[of n], auto) |
|
241 moreover have "square2 n i (2^n+j) - {(2^n+i - 1, 2^n+j)} : tiling Ls" |
|
242 by(rule IH)(insert pos_pow2[of n], auto) |
|
243 moreover have "square2 n (2^n+i) (2^n+j) - {(2^n+i, 2^n+j)} : tiling Ls" |
|
244 by(rule IH)(insert pos_pow2[of n], auto) |
|
245 ultimately |
|
246 have "square2 (n+1) i j - {(a,b)} - L0 (2^n+i - 1) (2^n+j - 1) \<in> tiling Ls" |
|
247 using a b `?A` |
|
248 by (clarsimp simp: square2_Suc L0_def Un_Diff Diff_insert_if) |
|
249 (fastsimp intro!: tiling_UnI DisjI1 DisjI2 square2_disj[THEN iffD2] |
|
250 simp:Int_Un_distrib2) |
|
251 } moreover |
|
252 { assume "?B" |
|
253 hence "square2 n (2^n+i) j - {(a,b)} : tiling Ls" using IH a b by auto |
|
254 moreover have "square2 n i j - {(2^n+i - 1,2^n+j - 1)} : tiling Ls" |
|
255 by(rule IH)(insert pos_pow2[of n], auto) |
|
256 moreover have "square2 n i (2^n+j) - {(2^n+i - 1, 2^n+j)} : tiling Ls" |
|
257 by(rule IH)(insert pos_pow2[of n], auto) |
|
258 moreover have "square2 n (2^n+i) (2^n+j) - {(2^n+i, 2^n+j)} : tiling Ls" |
|
259 by(rule IH)(insert pos_pow2[of n], auto) |
|
260 ultimately |
|
261 have "square2 (n+1) i j - {(a,b)} - L1 (2^n+i - 1) (2^n+j - 1) \<in> tiling Ls" |
|
262 using a b `?B` |
|
263 by (simp add: square2_Suc L1_def Un_Diff Diff_insert_if le_diff_conv2) |
|
264 (fastsimp intro!: tiling_UnI DisjI1 DisjI2 square2_disj[THEN iffD2] |
|
265 simp:Int_Un_distrib2) |
|
266 } moreover |
|
267 { assume "?C" |
|
268 hence "square2 n i (2^n+j) - {(a,b)} : tiling Ls" using IH a b by auto |
|
269 moreover have "square2 n i j - {(2^n+i - 1,2^n+j - 1)} : tiling Ls" |
|
270 by(rule IH)(insert pos_pow2[of n], auto) |
|
271 moreover have "square2 n (2^n+i) j - {(2^n+i, 2^n+j - 1)} : tiling Ls" |
|
272 by(rule IH)(insert pos_pow2[of n], auto) |
|
273 moreover have "square2 n (2^n+i) (2^n+j) - {(2^n+i, 2^n+j)} : tiling Ls" |
|
274 by(rule IH)(insert pos_pow2[of n], auto) |
|
275 ultimately |
|
276 have "square2 (n+1) i j - {(a,b)} - L3 (2^n+i - 1) (2^n+j - 1) \<in> tiling Ls" |
|
277 using a b `?C` |
|
278 by (simp add: square2_Suc L3_def Un_Diff Diff_insert_if le_diff_conv2) |
|
279 (fastsimp intro!: tiling_UnI DisjI1 DisjI2 square2_disj[THEN iffD2] |
|
280 simp:Int_Un_distrib2) |
|
281 } moreover |
|
282 { assume "?D" |
|
283 hence "square2 n (2^n+i) (2^n+j) -{(a,b)} : tiling Ls" using IH a b by auto |
|
284 moreover have "square2 n i j - {(2^n+i - 1,2^n+j - 1)} : tiling Ls" |
|
285 by(rule IH)(insert pos_pow2[of n], auto) |
|
286 moreover have "square2 n (2^n+i) j - {(2^n+i, 2^n+j - 1)} : tiling Ls" |
|
287 by(rule IH)(insert pos_pow2[of n], auto) |
|
288 moreover have "square2 n i (2^n+j) - {(2^n+i - 1, 2^n+j)} : tiling Ls" |
|
289 by(rule IH)(insert pos_pow2[of n], auto) |
|
290 ultimately |
|
291 have "square2 (n+1) i j - {(a,b)} - L2 (2^n+i - 1) (2^n+j - 1) \<in> tiling Ls" |
|
292 using a b `?D` |
|
293 by (simp add: square2_Suc L2_def Un_Diff Diff_insert_if le_diff_conv2) |
|
294 (fastsimp intro!: tiling_UnI DisjI1 DisjI2 square2_disj[THEN iffD2] |
|
295 simp:Int_Un_distrib2) |
|
296 } moreover |
|
297 have "?A \<Longrightarrow> L0 (2^n + i - 1) (2^n + j - 1) \<subseteq> square2 (n+1) i j - {(a, b)}" |
|
298 using a b by(simp add:L0_def) arith moreover |
|
299 have "?B \<Longrightarrow> L1 (2^n + i - 1) (2^n + j - 1) \<subseteq> square2 (n+1) i j - {(a, b)}" |
|
300 using a b by(simp add:L1_def) arith moreover |
|
301 have "?C \<Longrightarrow> L3 (2^n + i - 1) (2^n + j - 1) \<subseteq> square2 (n+1) i j - {(a, b)}" |
|
302 using a b by(simp add:L3_def) arith moreover |
|
303 have "?D \<Longrightarrow> L2 (2^n + i - 1) (2^n + j - 1) \<subseteq> square2 (n+1) i j - {(a, b)}" |
|
304 using a b by(simp add:L2_def) arith |
|
305 ultimately show ?case |
|
306 apply simp |
|
307 apply(erule disjE) |
|
308 apply (metis LinLs tiling_Diff1E) |
|
309 apply (metis LinLs tiling_Diff1E) |
|
310 done |
|
311 qed |
|
312 |
|
313 corollary Ls_can_tile00: |
|
314 "a < 2^n \<Longrightarrow> b < 2^n \<Longrightarrow> square2 n 0 0 - {(a, b)} \<in> tiling Ls" |
|
315 by(rule Ls_can_tile) auto |
146 |
316 |
147 end |
317 end |