src/HOL/Isar_examples/MutilatedCheckerboard.thy
author berghofe
Wed, 11 Jul 2007 11:14:51 +0200
changeset 23746 a455e69c31cc
parent 23373 ead82c82da9e
child 26813 6a4d5ca6d2e5
permissions -rw-r--r--
Adapted to new inductive definition package.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/Isar_examples/MutilatedCheckerboard.thy
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
7385
wenzelm
parents: 7383
diff changeset
     3
    Author:     Markus Wenzel, TU Muenchen (Isar document)
wenzelm
parents: 7383
diff changeset
     4
                Lawrence C Paulson, Cambridge University Computer Laboratory (original scripts)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
     5
*)
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
     6
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
     7
header {* The Mutilated Checker Board Problem *}
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
     8
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13187
diff changeset
     9
theory MutilatedCheckerboard imports Main begin
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    10
7968
964b65b4e433 improved presentation;
wenzelm
parents: 7874
diff changeset
    11
text {*
964b65b4e433 improved presentation;
wenzelm
parents: 7874
diff changeset
    12
 The Mutilated Checker Board Problem, formalized inductively.  See
964b65b4e433 improved presentation;
wenzelm
parents: 7874
diff changeset
    13
 \cite{paulson-mutilated-board} and
964b65b4e433 improved presentation;
wenzelm
parents: 7874
diff changeset
    14
 \url{http://isabelle.in.tum.de/library/HOL/Induct/Mutil.html} for the
964b65b4e433 improved presentation;
wenzelm
parents: 7874
diff changeset
    15
 original tactic script version.
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    16
*}
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    17
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    18
subsection {* Tilings *}
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    19
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23373
diff changeset
    20
inductive_set
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    21
  tiling :: "'a set set => 'a set set"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23373
diff changeset
    22
  for A :: "'a set set"
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23373
diff changeset
    23
  where
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    24
    empty: "{} : tiling A"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23373
diff changeset
    25
  | Un: "a : A ==> t : tiling A ==> a <= - t ==> a Un t : tiling A"
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    26
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    27
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    28
text "The union of two disjoint tilings is a tiling."
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    29
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    30
lemma tiling_Un:
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
    31
  assumes "t : tiling A" and "u : tiling A" and "t Int u = {}"
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
    32
  shows "t Un u : tiling A"
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    33
proof -
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    34
  let ?T = "tiling A"
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
    35
  from `t : ?T` and `t Int u = {}`
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
    36
  show "t Un u : ?T"
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    37
  proof (induct t)
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
    38
    case empty
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
    39
    with `u : ?T` show "{} Un u : ?T" by simp
9475
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    40
  next
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
    41
    case (Un a t)
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    42
    show "(a Un t) Un u : ?T"
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    43
    proof -
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    44
      have "a Un (t Un u) : ?T"
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
    45
	using `a : A`
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    46
      proof (rule tiling.Un)
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
    47
        from `(a Un t) Int u = {}` have "t Int u = {}" by blast
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
    48
        then show "t Un u: ?T" by (rule Un)
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
    49
        from `a <= - t` and `(a Un t) Int u = {}`
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
    50
	show "a <= - (t Un u)" by blast
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    51
      qed
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    52
      also have "a Un (t Un u) = (a Un t) Un u"
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    53
        by (simp only: Un_assoc)
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    54
      finally show ?thesis .
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
    55
    qed
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    56
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    57
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    58
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    59
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    60
subsection {* Basic properties of ``below'' *}
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    61
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    62
constdefs
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    63
  below :: "nat => nat set"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    64
  "below n == {i. i < n}"
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    65
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    66
lemma below_less_iff [iff]: "(i: below k) = (i < k)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    67
  by (simp add: below_def)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    68
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    69
lemma below_0: "below 0 = {}"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    70
  by (simp add: below_def)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    71
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    72
lemma Sigma_Suc1:
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    73
    "m = n + 1 ==> below m <*> B = ({n} <*> B) Un (below n <*> B)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    74
  by (simp add: below_def less_Suc_eq) blast
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    75
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    76
lemma Sigma_Suc2:
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
    77
    "m = n + 2 ==> A <*> below m =
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    78
      (A <*> {n}) Un (A <*> {n + 1}) Un (A <*> below n)"
13187
e5434b822a96 Modifications due to enhanced linear arithmetic.
nipkow
parents: 11987
diff changeset
    79
  by (auto simp add: below_def)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    80
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    81
lemmas Sigma_Suc = Sigma_Suc1 Sigma_Suc2
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    82
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    83
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    84
subsection {* Basic properties of ``evnodd'' *}
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    85
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    86
constdefs
7385
wenzelm
parents: 7383
diff changeset
    87
  evnodd :: "(nat * nat) set => nat => (nat * nat) set"
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
    88
  "evnodd A b == A Int {(i, j). (i + j) mod 2 = b}"
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    89
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    90
lemma evnodd_iff:
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
    91
    "(i, j): evnodd A b = ((i, j): A  & (i + j) mod 2 = b)"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    92
  by (simp add: evnodd_def)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    93
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    94
lemma evnodd_subset: "evnodd A b <= A"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    95
  by (unfold evnodd_def, rule Int_lower1)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    96
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    97
lemma evnoddD: "x : evnodd A b ==> x : A"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
    98
  by (rule subsetD, rule evnodd_subset)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    99
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   100
lemma evnodd_finite: "finite A ==> finite (evnodd A b)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   101
  by (rule finite_subset, rule evnodd_subset)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   102
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   103
lemma evnodd_Un: "evnodd (A Un B) b = evnodd A b Un evnodd B b"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   104
  by (unfold evnodd_def) blast
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   105
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   106
lemma evnodd_Diff: "evnodd (A - B) b = evnodd A b - evnodd B b"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   107
  by (unfold evnodd_def) blast
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   108
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   109
lemma evnodd_empty: "evnodd {} b = {}"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   110
  by (simp add: evnodd_def)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   111
7385
wenzelm
parents: 7383
diff changeset
   112
lemma evnodd_insert: "evnodd (insert (i, j) C) b =
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   113
    (if (i + j) mod 2 = b
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   114
      then insert (i, j) (evnodd C b) else evnodd C b)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   115
  by (simp add: evnodd_def) blast
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   116
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   117
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   118
subsection {* Dominoes *}
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   119
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23373
diff changeset
   120
inductive_set
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   121
  domino :: "(nat * nat) set set"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23373
diff changeset
   122
  where
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
   123
    horiz: "{(i, j), (i, j + 1)} : domino"
23746
a455e69c31cc Adapted to new inductive definition package.
berghofe
parents: 23373
diff changeset
   124
  | vertl: "{(i, j), (i + 1, j)} : domino"
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   125
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
   126
lemma dominoes_tile_row:
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   127
  "{i} <*> below (2 * n) : tiling domino"
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   128
  (is "?B n : ?T")
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   129
proof (induct n)
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   130
  case 0
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   131
  show ?case by (simp add: below_0 tiling.empty)
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   132
next
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   133
  case (Suc n)
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   134
  let ?a = "{i} <*> {2 * n + 1} Un {i} <*> {2 * n}"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   135
  have "?B (Suc n) = ?a Un ?B n"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   136
    by (auto simp add: Sigma_Suc Un_assoc)
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   137
  also have "... : ?T"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   138
  proof (rule tiling.Un)
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   139
    have "{(i, 2 * n), (i, 2 * n + 1)} : domino"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   140
      by (rule domino.horiz)
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   141
    also have "{(i, 2 * n), (i, 2 * n + 1)} = ?a" by blast
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   142
    finally show "... : domino" .
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   143
    show "?B n : ?T" by (rule Suc)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   144
    show "?a <= - ?B n" by blast
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   145
  qed
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   146
  finally show ?case .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   147
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   148
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   149
lemma dominoes_tile_matrix:
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   150
  "below m <*> below (2 * n) : tiling domino"
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   151
  (is "?B m : ?T")
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   152
proof (induct m)
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   153
  case 0
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   154
  show ?case by (simp add: below_0 tiling.empty)
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   155
next
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   156
  case (Suc m)
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   157
  let ?t = "{m} <*> below (2 * n)"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   158
  have "?B (Suc m) = ?t Un ?B m" by (simp add: Sigma_Suc)
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   159
  also have "... : ?T"
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
   160
  proof (rule tiling_Un)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   161
    show "?t : ?T" by (rule dominoes_tile_row)
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   162
    show "?B m : ?T" by (rule Suc)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   163
    show "?t Int ?B m = {}" by blast
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   164
  qed
11987
bf31b35949ce tuned induct proofs;
wenzelm
parents: 11704
diff changeset
   165
  finally show ?case .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   166
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   167
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   168
lemma domino_singleton:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   169
  assumes d: "d : domino" and "b < 2"
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   170
  shows "EX i j. evnodd d b = {(i, j)}"  (is "?P d")
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   171
  using d
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   172
proof induct
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   173
  from `b < 2` have b_cases: "b = 0 | b = 1" by arith
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   174
  fix i j
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   175
  note [simp] = evnodd_empty evnodd_insert mod_Suc
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   176
  from b_cases show "?P {(i, j), (i, j + 1)}" by rule auto
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   177
  from b_cases show "?P {(i, j), (i + 1, j)}" by rule auto
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   178
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   179
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   180
lemma domino_finite:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   181
  assumes d: "d: domino"
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   182
  shows "finite d"
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   183
  using d
18192
wenzelm
parents: 18153
diff changeset
   184
proof induct
wenzelm
parents: 18153
diff changeset
   185
  fix i j :: nat
22273
9785397cc344 Adapted to changes in Finite_Set theory.
berghofe
parents: 18241
diff changeset
   186
  show "finite {(i, j), (i, j + 1)}" by (intro finite.intros)
9785397cc344 Adapted to changes in Finite_Set theory.
berghofe
parents: 18241
diff changeset
   187
  show "finite {(i, j), (i + 1, j)}" by (intro finite.intros)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   188
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   189
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   190
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   191
subsection {* Tilings of dominoes *}
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   192
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   193
lemma tiling_domino_finite:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   194
  assumes t: "t : tiling domino"  (is "t : ?T")
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   195
  shows "finite t"  (is "?F t")
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   196
  using t
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   197
proof induct
22273
9785397cc344 Adapted to changes in Finite_Set theory.
berghofe
parents: 18241
diff changeset
   198
  show "?F {}" by (rule finite.emptyI)
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   199
  fix a t assume "?F t"
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   200
  assume "a : domino" then have "?F a" by (rule domino_finite)
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
   201
  from this and `?F t` show "?F (a Un t)" by (rule finite_UnI)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   202
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   203
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   204
lemma tiling_domino_01:
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   205
  assumes t: "t : tiling domino"  (is "t : ?T")
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   206
  shows "card (evnodd t 0) = card (evnodd t 1)"
18241
afdba6b3e383 tuned induction proofs;
wenzelm
parents: 18192
diff changeset
   207
  using t
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   208
proof induct
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   209
  case empty
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   210
  show ?case by (simp add: evnodd_def)
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   211
next
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   212
  case (Un a t)
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   213
  let ?e = evnodd
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   214
  note hyp = `card (?e t 0) = card (?e t 1)`
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   215
    and at = `a <= - t`
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   216
  have card_suc:
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   217
    "!!b. b < 2 ==> card (?e (a Un t) b) = Suc (card (?e t b))"
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   218
  proof -
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   219
    fix b :: nat assume "b < 2"
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   220
    have "?e (a Un t) b = ?e a b Un ?e t b" by (rule evnodd_Un)
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   221
    also obtain i j where e: "?e a b = {(i, j)}"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   222
    proof -
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
   223
      from `a \<in> domino` and `b < 2`
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   224
      have "EX i j. ?e a b = {(i, j)}" by (rule domino_singleton)
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   225
      then show ?thesis by (blast intro: that)
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   226
    qed
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   227
    also have "... Un ?e t b = insert (i, j) (?e t b)" by simp
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   228
    also have "card ... = Suc (card (?e t b))"
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   229
    proof (rule card_insert_disjoint)
23373
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
   230
      from `t \<in> tiling domino` have "finite t"
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
   231
	by (rule tiling_domino_finite)
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
   232
      then show "finite (?e t b)"
ead82c82da9e tuned proofs: avoid implicit prems;
wenzelm
parents: 22273
diff changeset
   233
        by (rule evnodd_finite)
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   234
      from e have "(i, j) : ?e a b" by simp
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   235
      with at show "(i, j) ~: ?e t b" by (blast dest: evnoddD)
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   236
    qed
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   237
    finally show "?thesis b" .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   238
  qed
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   239
  then have "card (?e (a Un t) 0) = Suc (card (?e t 0))" by simp
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   240
  also from hyp have "card (?e t 0) = card (?e t 1)" .
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   241
  also from card_suc have "Suc ... = card (?e (a Un t) 1)"
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   242
    by simp
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   243
  finally show ?case .
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   244
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   245
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   246
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   247
subsection {* Main theorem *}
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   248
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   249
constdefs
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   250
  mutilated_board :: "nat => nat => (nat * nat) set"
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   251
  "mutilated_board m n ==
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   252
    below (2 * (m + 1)) <*> below (2 * (n + 1))
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   253
      - {(0, 0)} - {(2 * m + 1, 2 * n + 1)}"
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   254
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   255
theorem mutil_not_tiling: "mutilated_board m n ~: tiling domino"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   256
proof (unfold mutilated_board_def)
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   257
  let ?T = "tiling domino"
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   258
  let ?t = "below (2 * (m + 1)) <*> below (2 * (n + 1))"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   259
  let ?t' = "?t - {(0, 0)}"
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   260
  let ?t'' = "?t' - {(2 * m + 1, 2 * n + 1)}"
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   261
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   262
  show "?t'' ~: ?T"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   263
  proof
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   264
    have t: "?t : ?T" by (rule dominoes_tile_matrix)
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   265
    assume t'': "?t'' : ?T"
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   266
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   267
    let ?e = evnodd
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   268
    have fin: "finite (?e ?t 0)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   269
      by (rule evnodd_finite, rule tiling_domino_finite, rule t)
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   270
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   271
    note [simp] = evnodd_iff evnodd_empty evnodd_insert evnodd_Diff
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   272
    have "card (?e ?t'' 0) < card (?e ?t' 0)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   273
    proof -
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   274
      have "card (?e ?t' 0 - {(2 * m + 1, 2 * n + 1)})
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   275
        < card (?e ?t' 0)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   276
      proof (rule card_Diff1_less)
10408
d8b3613158b1 improved: 'induct' handle non-atomic goals;
wenzelm
parents: 10387
diff changeset
   277
        from _ fin show "finite (?e ?t' 0)"
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   278
          by (rule finite_subset) auto
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   279
        show "(2 * m + 1, 2 * n + 1) : ?e ?t' 0" by simp
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   280
      qed
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   281
      then show ?thesis by simp
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   282
    qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   283
    also have "... < card (?e ?t 0)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   284
    proof -
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   285
      have "(0, 0) : ?e ?t 0" by simp
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   286
      with fin have "card (?e ?t 0 - {(0, 0)}) < card (?e ?t 0)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   287
        by (rule card_Diff1_less)
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   288
      then show ?thesis by simp
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   289
    qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   290
    also from t have "... = card (?e ?t 1)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   291
      by (rule tiling_domino_01)
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   292
    also have "?e ?t 1 = ?e ?t'' 1" by simp
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   293
    also from t'' have "card ... = card (?e ?t'' 0)"
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   294
      by (rule tiling_domino_01 [symmetric])
18153
a084aa91f701 tuned proofs;
wenzelm
parents: 16417
diff changeset
   295
    finally have "... < ..." . then show False ..
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   296
  qed
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   297
qed
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   298
10007
64bf7da1994a isar-strip-terminators;
wenzelm
parents: 9941
diff changeset
   299
end