12173
|
1 |
(* Title: ZF/Induct/Mutil.thy
|
12088
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1996 University of Cambridge
|
|
5 |
*)
|
|
6 |
|
12173
|
7 |
header {* The Mutilated Chess Board Problem, formalized inductively *}
|
|
8 |
|
16417
|
9 |
theory Mutil imports Main begin
|
12173
|
10 |
|
|
11 |
text {*
|
|
12 |
Originator is Max Black, according to J A Robinson. Popularized as
|
|
13 |
the Mutilated Checkerboard Problem by J McCarthy.
|
|
14 |
*}
|
|
15 |
|
12088
|
16 |
consts
|
12173
|
17 |
domino :: i
|
|
18 |
tiling :: "i => i"
|
|
19 |
|
|
20 |
inductive
|
|
21 |
domains "domino" \<subseteq> "Pow(nat \<times> nat)"
|
|
22 |
intros
|
|
23 |
horiz: "[| i \<in> nat; j \<in> nat |] ==> {<i,j>, <i,succ(j)>} \<in> domino"
|
|
24 |
vertl: "[| i \<in> nat; j \<in> nat |] ==> {<i,j>, <succ(i),j>} \<in> domino"
|
|
25 |
type_intros empty_subsetI cons_subsetI PowI SigmaI nat_succI
|
12088
|
26 |
|
|
27 |
inductive
|
12173
|
28 |
domains "tiling(A)" \<subseteq> "Pow(Union(A))"
|
|
29 |
intros
|
|
30 |
empty: "0 \<in> tiling(A)"
|
|
31 |
Un: "[| a \<in> A; t \<in> tiling(A); a Int t = 0 |] ==> a Un t \<in> tiling(A)"
|
|
32 |
type_intros empty_subsetI Union_upper Un_least PowI
|
|
33 |
type_elims PowD [elim_format]
|
|
34 |
|
24893
|
35 |
definition
|
|
36 |
evnodd :: "[i, i] => i" where
|
12173
|
37 |
"evnodd(A,b) == {z \<in> A. \<exists>i j. z = <i,j> \<and> (i #+ j) mod 2 = b}"
|
|
38 |
|
|
39 |
|
12185
|
40 |
subsection {* Basic properties of evnodd *}
|
12173
|
41 |
|
|
42 |
lemma evnodd_iff: "<i,j>: evnodd(A,b) <-> <i,j>: A & (i#+j) mod 2 = b"
|
|
43 |
by (unfold evnodd_def) blast
|
|
44 |
|
|
45 |
lemma evnodd_subset: "evnodd(A, b) \<subseteq> A"
|
|
46 |
by (unfold evnodd_def) blast
|
|
47 |
|
|
48 |
lemma Finite_evnodd: "Finite(X) ==> Finite(evnodd(X,b))"
|
|
49 |
by (rule lepoll_Finite, rule subset_imp_lepoll, rule evnodd_subset)
|
|
50 |
|
|
51 |
lemma evnodd_Un: "evnodd(A Un B, b) = evnodd(A,b) Un evnodd(B,b)"
|
|
52 |
by (simp add: evnodd_def Collect_Un)
|
|
53 |
|
|
54 |
lemma evnodd_Diff: "evnodd(A - B, b) = evnodd(A,b) - evnodd(B,b)"
|
|
55 |
by (simp add: evnodd_def Collect_Diff)
|
|
56 |
|
|
57 |
lemma evnodd_cons [simp]:
|
|
58 |
"evnodd(cons(<i,j>,C), b) =
|
|
59 |
(if (i#+j) mod 2 = b then cons(<i,j>, evnodd(C,b)) else evnodd(C,b))"
|
|
60 |
by (simp add: evnodd_def Collect_cons)
|
|
61 |
|
|
62 |
lemma evnodd_0 [simp]: "evnodd(0, b) = 0"
|
|
63 |
by (simp add: evnodd_def)
|
|
64 |
|
|
65 |
|
12185
|
66 |
subsection {* Dominoes *}
|
12173
|
67 |
|
|
68 |
lemma domino_Finite: "d \<in> domino ==> Finite(d)"
|
|
69 |
by (blast intro!: Finite_cons Finite_0 elim: domino.cases)
|
|
70 |
|
12185
|
71 |
lemma domino_singleton:
|
|
72 |
"[| d \<in> domino; b<2 |] ==> \<exists>i' j'. evnodd(d,b) = {<i',j'>}"
|
12173
|
73 |
apply (erule domino.cases)
|
|
74 |
apply (rule_tac [2] k1 = "i#+j" in mod2_cases [THEN disjE])
|
|
75 |
apply (rule_tac k1 = "i#+j" in mod2_cases [THEN disjE])
|
|
76 |
apply (rule add_type | assumption)+
|
|
77 |
(*Four similar cases: case (i#+j) mod 2 = b, 2#-b, ...*)
|
|
78 |
apply (auto simp add: mod_succ succ_neq_self dest: ltD)
|
|
79 |
done
|
12088
|
80 |
|
|
81 |
|
12185
|
82 |
subsection {* Tilings *}
|
12173
|
83 |
|
|
84 |
text {* The union of two disjoint tilings is a tiling *}
|
|
85 |
|
|
86 |
lemma tiling_UnI:
|
|
87 |
"t \<in> tiling(A) ==> u \<in> tiling(A) ==> t Int u = 0 ==> t Un u \<in> tiling(A)"
|
|
88 |
apply (induct set: tiling)
|
|
89 |
apply (simp add: tiling.intros)
|
|
90 |
apply (simp add: Un_assoc subset_empty_iff [THEN iff_sym])
|
|
91 |
apply (blast intro: tiling.intros)
|
|
92 |
done
|
|
93 |
|
|
94 |
lemma tiling_domino_Finite: "t \<in> tiling(domino) ==> Finite(t)"
|
18415
|
95 |
apply (induct set: tiling)
|
12173
|
96 |
apply (rule Finite_0)
|
|
97 |
apply (blast intro!: Finite_Un intro: domino_Finite)
|
|
98 |
done
|
|
99 |
|
|
100 |
lemma tiling_domino_0_1: "t \<in> tiling(domino) ==> |evnodd(t,0)| = |evnodd(t,1)|"
|
18415
|
101 |
apply (induct set: tiling)
|
12173
|
102 |
apply (simp add: evnodd_def)
|
|
103 |
apply (rule_tac b1 = 0 in domino_singleton [THEN exE])
|
|
104 |
prefer 2
|
|
105 |
apply simp
|
|
106 |
apply assumption
|
|
107 |
apply (rule_tac b1 = 1 in domino_singleton [THEN exE])
|
|
108 |
prefer 2
|
|
109 |
apply simp
|
|
110 |
apply assumption
|
|
111 |
apply safe
|
|
112 |
apply (subgoal_tac "\<forall>p b. p \<in> evnodd (a,b) --> p\<notin>evnodd (t,b)")
|
|
113 |
apply (simp add: evnodd_Un Un_cons tiling_domino_Finite
|
|
114 |
evnodd_subset [THEN subset_Finite] Finite_imp_cardinal_cons)
|
|
115 |
apply (blast dest!: evnodd_subset [THEN subsetD] elim: equalityE)
|
|
116 |
done
|
12088
|
117 |
|
12185
|
118 |
lemma dominoes_tile_row:
|
|
119 |
"[| i \<in> nat; n \<in> nat |] ==> {i} * (n #+ n) \<in> tiling(domino)"
|
12173
|
120 |
apply (induct_tac n)
|
|
121 |
apply (simp add: tiling.intros)
|
|
122 |
apply (simp add: Un_assoc [symmetric] Sigma_succ2)
|
|
123 |
apply (rule tiling.intros)
|
|
124 |
prefer 2 apply assumption
|
|
125 |
apply (rename_tac n')
|
|
126 |
apply (subgoal_tac (*seems the easiest way of turning one to the other*)
|
12185
|
127 |
"{i}*{succ (n'#+n') } Un {i}*{n'#+n'} =
|
|
128 |
{<i,n'#+n'>, <i,succ (n'#+n') >}")
|
12173
|
129 |
prefer 2 apply blast
|
|
130 |
apply (simp add: domino.horiz)
|
|
131 |
apply (blast elim: mem_irrefl mem_asym)
|
|
132 |
done
|
|
133 |
|
12185
|
134 |
lemma dominoes_tile_matrix:
|
|
135 |
"[| m \<in> nat; n \<in> nat |] ==> m * (n #+ n) \<in> tiling(domino)"
|
12173
|
136 |
apply (induct_tac m)
|
|
137 |
apply (simp add: tiling.intros)
|
|
138 |
apply (simp add: Sigma_succ1)
|
|
139 |
apply (blast intro: tiling_UnI dominoes_tile_row elim: mem_irrefl)
|
|
140 |
done
|
|
141 |
|
|
142 |
lemma eq_lt_E: "[| x=y; x<y |] ==> P"
|
|
143 |
by auto
|
|
144 |
|
|
145 |
theorem mutil_not_tiling: "[| m \<in> nat; n \<in> nat;
|
|
146 |
t = (succ(m)#+succ(m))*(succ(n)#+succ(n));
|
|
147 |
t' = t - {<0,0>} - {<succ(m#+m), succ(n#+n)>} |]
|
|
148 |
==> t' \<notin> tiling(domino)"
|
|
149 |
apply (rule notI)
|
|
150 |
apply (drule tiling_domino_0_1)
|
|
151 |
apply (erule_tac x = "|?A|" in eq_lt_E)
|
|
152 |
apply (subgoal_tac "t \<in> tiling (domino)")
|
|
153 |
prefer 2 (*Requires a small simpset that won't move the succ applications*)
|
|
154 |
apply (simp only: nat_succI add_type dominoes_tile_matrix)
|
12185
|
155 |
apply (simp add: evnodd_Diff mod2_add_self mod2_succ_succ
|
|
156 |
tiling_domino_0_1 [symmetric])
|
12173
|
157 |
apply (rule lt_trans)
|
|
158 |
apply (rule Finite_imp_cardinal_Diff,
|
|
159 |
simp add: tiling_domino_Finite Finite_evnodd Finite_Diff,
|
|
160 |
simp add: evnodd_iff nat_0_le [THEN ltD] mod2_add_self)+
|
|
161 |
done
|
12088
|
162 |
|
|
163 |
end
|