src/HOL/Isar_examples/MutilatedCheckerboard.thy
author wenzelm
Sun, 30 Jul 2000 13:03:49 +0200
changeset 9475 b24516d96847
parent 8814 0a5edcbe0695
child 9596 6d6bf351b2cc
permissions -rw-r--r--
adapted obtain; tuned;
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
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
     7
header {* The Mutilated Checker Board Problem *};
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
     8
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
     9
theory MutilatedCheckerboard = Main:;
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.
964b65b4e433 improved presentation;
wenzelm
parents: 7874
diff changeset
    16
*};
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    17
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    18
subsection {* Tilings *};
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    19
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    20
consts
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    21
  tiling :: "'a set set => 'a set set";
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    22
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    23
inductive "tiling A"
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    24
  intrs
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    25
    empty: "{} : tiling A"
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
    26
    Un:    "a : A ==> t : tiling A ==> a <= - t
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
    27
              ==> a Un t : tiling A";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    28
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    29
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
    30
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
    31
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    32
lemma tiling_Un:
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
    33
  "t : tiling A --> u : tiling A --> t Int u = {}
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
    34
    --> t Un u : tiling A";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    35
proof;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
    36
  assume "t : tiling A" (is "_ : ?T");
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
    37
  thus "u : ?T --> t Int u = {} --> t Un u : ?T" (is "?P t");
9475
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    38
  proof (induct (stripped) t);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    39
    assume "u : ?T" "{} Int u = {}"
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    40
    thus "{} Un u : ?T" by simp;
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    41
  next
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    42
    fix a t;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
    43
    assume "a : A" "t : ?T" "?P t" "a <= - t";
9475
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    44
    assume "u : ?T" "(a Un t) Int u = {}";
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    45
    have hyp: "t Un u: ?T"; by (blast!);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    46
    have "a <= - (t Un u)"; by (blast!);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    47
    with _ hyp; have "a Un (t Un u) : ?T"; by (rule tiling.Un);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    48
    also; have "a Un (t Un u) = (a Un t) Un u";
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    49
      by (simp only: Un_assoc);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
    50
    finally; show "... : ?T"; .;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    51
  qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    52
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    53
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    54
7874
180364256231 improved presentation;
wenzelm
parents: 7800
diff changeset
    55
subsection {* Basic properties of ``below'' *};
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    56
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    57
constdefs
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    58
  below :: "nat => nat set"
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    59
  "below n == {i. i < n}";
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    60
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    61
lemma below_less_iff [iff]: "(i: below k) = (i < k)";
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    62
  by (simp add: below_def);
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    63
7385
wenzelm
parents: 7383
diff changeset
    64
lemma below_0: "below 0 = {}";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    65
  by (simp add: below_def);
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    66
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    67
lemma Sigma_Suc1:
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
    68
    "m = n + 1 ==> below m <*> B = ({n} <*> B) Un (below n <*> B)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    69
  by (simp add: below_def less_Suc_eq) blast;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    70
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    71
lemma Sigma_Suc2:
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
    72
    "m = n + 2 ==> A <*> below m = (A <*> {n}) Un (A <*> {n + 1}) Un (A <*> below n)";
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
    73
  by (auto simp add: below_def) arith;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    74
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    75
lemmas Sigma_Suc = Sigma_Suc1 Sigma_Suc2;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    76
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    77
7874
180364256231 improved presentation;
wenzelm
parents: 7800
diff changeset
    78
subsection {* Basic properties of ``evnodd'' *};
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    79
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    80
constdefs
7385
wenzelm
parents: 7383
diff changeset
    81
  evnodd :: "(nat * nat) set => nat => (nat * nat) set"
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
    82
  "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
    83
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
    84
lemma evnodd_iff:
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
    85
    "(i, j): evnodd A b = ((i, j): A  & (i + j) mod #2 = b)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    86
  by (simp add: evnodd_def);
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    87
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    88
lemma evnodd_subset: "evnodd A b <= A";
7385
wenzelm
parents: 7383
diff changeset
    89
  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
    90
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    91
lemma evnoddD: "x : evnodd A b ==> x : A";
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    92
  by (rule subsetD, rule evnodd_subset);
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    93
7385
wenzelm
parents: 7383
diff changeset
    94
lemma evnodd_finite: "finite A ==> finite (evnodd A b)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    95
  by (rule finite_subset, rule evnodd_subset);
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    96
7385
wenzelm
parents: 7383
diff changeset
    97
lemma evnodd_Un: "evnodd (A Un B) b = evnodd A b Un evnodd B b";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    98
  by (unfold evnodd_def) blast;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
    99
7385
wenzelm
parents: 7383
diff changeset
   100
lemma evnodd_Diff: "evnodd (A - B) b = evnodd A b - evnodd B b";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   101
  by (unfold evnodd_def) blast;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   102
7385
wenzelm
parents: 7383
diff changeset
   103
lemma evnodd_empty: "evnodd {} b = {}";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   104
  by (simp add: evnodd_def);
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   105
7385
wenzelm
parents: 7383
diff changeset
   106
lemma evnodd_insert: "evnodd (insert (i, j) C) b =
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
   107
    (if (i + j) mod #2 = b
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   108
      then insert (i, j) (evnodd C b) else evnodd C b)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   109
  by (simp add: evnodd_def) blast;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   110
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   111
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   112
subsection {* Dominoes *};
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   113
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   114
consts 
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   115
  domino  :: "(nat * nat) set set";
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
inductive domino
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   118
  intrs
7385
wenzelm
parents: 7383
diff changeset
   119
    horiz:  "{(i, j), (i, j + 1)} : domino"
wenzelm
parents: 7383
diff changeset
   120
    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
   121
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
   122
lemma dominoes_tile_row:
8703
816d8f6513be Times -> <*>
nipkow
parents: 8674
diff changeset
   123
  "{i} <*> below (2 * n) : tiling domino"
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   124
  (is "?P n" is "?B n : ?T");
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   125
proof (induct n);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   126
  show "?P 0"; by (simp add: below_0 tiling.empty);
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   127
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   128
  fix n; assume hyp: "?P n";
8703
816d8f6513be Times -> <*>
nipkow
parents: 8674
diff changeset
   129
  let ?a = "{i} <*> {2 * n + 1} Un {i} <*> {2 * n}";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   130
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
   131
  have "?B (Suc n) = ?a Un ?B n";
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
   132
    by (auto simp add: Sigma_Suc Un_assoc);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   133
  also; have "... : ?T";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   134
  proof (rule tiling.Un);
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   135
    have "{(i, 2 * n), (i, 2 * n + 1)} : domino";
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   136
      by (rule domino.horiz);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   137
    also; have "{(i, 2 * n), (i, 2 * n + 1)} = ?a"; by blast;
7385
wenzelm
parents: 7383
diff changeset
   138
    finally; show "... : domino"; .;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   139
    from hyp; show "?B n : ?T"; .;
9475
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   140
    show "?a <= - ?B n"; by blast;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   141
  qed;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   142
  finally; show "?P (Suc n)"; .;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   143
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   144
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   145
lemma dominoes_tile_matrix:
8703
816d8f6513be Times -> <*>
nipkow
parents: 8674
diff changeset
   146
  "below m <*> below (2 * n) : tiling domino"
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   147
  (is "?P m" is "?B m : ?T");
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   148
proof (induct m);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   149
  show "?P 0"; by (simp add: below_0 tiling.empty);
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   150
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   151
  fix m; assume hyp: "?P m";
8703
816d8f6513be Times -> <*>
nipkow
parents: 8674
diff changeset
   152
  let ?t = "{m} <*> below (2 * n)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   153
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   154
  have "?B (Suc m) = ?t Un ?B m"; by (simp add: Sigma_Suc);
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   155
  also; have "... : ?T";
7385
wenzelm
parents: 7383
diff changeset
   156
  proof (rule tiling_Un [rulify]);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   157
    show "?t : ?T"; by (rule dominoes_tile_row);
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   158
    from hyp; show "?B m : ?T"; .;
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   159
    show "?t Int ?B m = {}"; by blast;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   160
  qed;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   161
  finally; show "?P (Suc m)"; .;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   162
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   163
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   164
lemma domino_singleton:
8814
0a5edcbe0695 adapted to new arithmetic simprocs;
wenzelm
parents: 8703
diff changeset
   165
  "d : domino ==> b < 2 ==> EX i j. evnodd d b = {(i, j)}";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   166
proof -;
7565
bfa85f429629 accomodate refined facts handling;
wenzelm
parents: 7480
diff changeset
   167
  assume b: "b < 2";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   168
  assume "d : domino";
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   169
  thus ?thesis (is "?P d");
8297
f5fdb69ad4d2 simplified induct method;
wenzelm
parents: 8281
diff changeset
   170
  proof induct;
7565
bfa85f429629 accomodate refined facts handling;
wenzelm
parents: 7480
diff changeset
   171
    from b; have b_cases: "b = 0 | b = 1"; by arith;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   172
    fix i j;
7385
wenzelm
parents: 7383
diff changeset
   173
    note [simp] = evnodd_empty evnodd_insert mod_Suc;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   174
    from b_cases; show "?P {(i, j), (i, j + 1)}"; by rule auto;
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   175
    from b_cases; show "?P {(i, j), (i + 1, j)}"; by rule auto;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   176
  qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   177
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   178
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   179
lemma domino_finite: "d: domino ==> finite d";
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   180
proof (induct set: domino);
7434
wenzelm
parents: 7385
diff changeset
   181
  fix i j :: nat;
7385
wenzelm
parents: 7383
diff changeset
   182
  show "finite {(i, j), (i, j + 1)}"; by (intro Finites.intrs);
wenzelm
parents: 7383
diff changeset
   183
  show "finite {(i, j), (i + 1, j)}"; by (intro Finites.intrs);
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   184
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   185
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   186
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   187
subsection {* Tilings of dominoes *};
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   188
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   189
lemma tiling_domino_finite:
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   190
  "t : tiling domino ==> finite t" (is "t : ?T ==> ?F t");
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   191
proof -;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   192
  assume "t : ?T";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   193
  thus "?F t";
8297
f5fdb69ad4d2 simplified induct method;
wenzelm
parents: 8281
diff changeset
   194
  proof induct;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   195
    show "?F {}"; by (rule Finites.emptyI);
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   196
    fix a t; assume "?F t";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   197
    assume "a : domino"; hence "?F a"; by (rule domino_finite);
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   198
    thus "?F (a Un t)"; by (rule finite_UnI);
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   199
  qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   200
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   201
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   202
lemma tiling_domino_01:
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   203
  "t : tiling domino ==> card (evnodd t 0) = card (evnodd t 1)"
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   204
  (is "t : ?T ==> ?P t");
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   205
proof -;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   206
  assume "t : ?T";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   207
  thus "?P t";
8297
f5fdb69ad4d2 simplified induct method;
wenzelm
parents: 8281
diff changeset
   208
  proof induct;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   209
    show "?P {}"; by (simp add: evnodd_def);
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   210
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   211
    fix a t;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   212
    let ?e = evnodd;
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   213
    assume "a : domino" "t : ?T"
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   214
      and hyp: "card (?e t 0) = card (?e t 1)"
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   215
      and "a <= - t";
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   216
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   217
    have card_suc:
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   218
      "!!b. b < 2 ==> card (?e (a Un t) b) = Suc (card (?e t b))";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   219
    proof -;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   220
      fix b; assume "b < 2";
9475
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   221
      have "?e (a Un t) b = ?e a b Un ?e t b"; by (rule evnodd_Un);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   222
      also; obtain i j where "?e a b = {(i, j)}";
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   223
      proof -;
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   224
	have "EX i j. ?e a b = {(i, j)}"; by (rule domino_singleton);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   225
	thus ?thesis; by blast;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   226
      qed;
9475
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   227
      also; have "... Un ?e t b = insert (i, j) (?e t b)"; by simp;
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   228
      also; have "card ... = Suc (card (?e t b))";
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   229
      proof (rule card_insert_disjoint);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   230
	show "finite (?e t b)";
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   231
          by (rule evnodd_finite, rule tiling_domino_finite);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   232
	have "(i, j) : ?e a b"; by (simp!);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   233
	thus "(i, j) ~: ?e t b"; by (blast! dest: evnoddD);
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   234
      qed;
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   235
      finally; show "?thesis b"; .;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   236
    qed;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   237
    hence "card (?e (a Un t) 0) = Suc (card (?e t 0))"; by simp;
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   238
    also; from hyp; have "card (?e t 0) = card (?e t 1)"; .;
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   239
    also; from card_suc; have "Suc ... = card (?e (a Un t) 1)";
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   240
      by simp;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   241
    finally; show "?P (a Un t)"; .;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   242
  qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   243
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   244
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   245
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   246
subsection {* Main theorem *};
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   247
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   248
constdefs
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   249
  mutilated_board :: "nat => nat => (nat * nat) set"
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   250
  "mutilated_board m n ==
8703
816d8f6513be Times -> <*>
nipkow
parents: 8674
diff changeset
   251
    below (2 * (m + 1)) <*> below (2 * (n + 1))
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   252
      - {(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
   253
7385
wenzelm
parents: 7383
diff changeset
   254
theorem mutil_not_tiling: "mutilated_board m n ~: tiling domino";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   255
proof (unfold mutilated_board_def);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   256
  let ?T = "tiling domino";
8703
816d8f6513be Times -> <*>
nipkow
parents: 8674
diff changeset
   257
  let ?t = "below (2 * (m + 1)) <*> below (2 * (n + 1))";
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   258
  let ?t' = "?t - {(0, 0)}";
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   259
  let ?t'' = "?t' - {(2 * m + 1, 2 * n + 1)}";
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   260
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   261
  show "?t'' ~: ?T";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   262
  proof;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   263
    have t: "?t : ?T"; by (rule dominoes_tile_matrix);
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   264
    assume t'': "?t'' : ?T";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   265
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   266
    let ?e = evnodd;
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   267
    have fin: "finite (?e ?t 0)";
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   268
      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
   269
7385
wenzelm
parents: 7383
diff changeset
   270
    note [simp] = evnodd_iff evnodd_empty evnodd_insert evnodd_Diff;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   271
    have "card (?e ?t'' 0) < card (?e ?t' 0)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   272
    proof -;
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
   273
      have "card (?e ?t' 0 - {(2 * m + 1, 2 * n + 1)})
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
   274
        < card (?e ?t' 0)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   275
      proof (rule card_Diff1_less);
8674
ac6c028e0249 fixed goal selection;
wenzelm
parents: 8297
diff changeset
   276
	from _ fin; show "finite (?e ?t' 0)";
9475
b24516d96847 adapted obtain;
wenzelm
parents: 8814
diff changeset
   277
          by (rule finite_subset) auto;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   278
	show "(2 * m + 1, 2 * n + 1) : ?e ?t' 0"; by simp;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   279
      qed;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   280
      thus ?thesis; by simp;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   281
    qed;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   282
    also; have "... < card (?e ?t 0)";
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   283
    proof -;
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   284
      have "(0, 0) : ?e ?t 0"; by simp;
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   285
      with fin; have "card (?e ?t 0 - {(0, 0)}) < card (?e ?t 0)";
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   286
        by (rule card_Diff1_less);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   287
      thus ?thesis; by simp;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   288
    qed;
7800
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
   289
    also; from t; have "... = card (?e ?t 1)";
8ee919e42174 improved presentation;
wenzelm
parents: 7761
diff changeset
   290
      by (rule tiling_domino_01);
7480
0a0e0dbe1269 replaced ?? by ?;
wenzelm
parents: 7447
diff changeset
   291
    also; have "?e ?t 1 = ?e ?t'' 1"; by simp;
7761
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   292
    also; from t''; have "card ... = card (?e ?t'' 0)";
7fab9592384f improved presentation;
wenzelm
parents: 7565
diff changeset
   293
      by (rule tiling_domino_01 [RS sym]);
7874
180364256231 improved presentation;
wenzelm
parents: 7800
diff changeset
   294
    finally; have "... < ..."; .; thus False; ..;
7382
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   295
  qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   296
qed;
33c01075d343 The Mutilated Chess Board Problem -- Isar'ized version of HOL/Inductive/Mutil;
wenzelm
parents:
diff changeset
   297
7383
9c4ef0d3f36c added Isar_examples/MutilatedCheckerboard.thy;
wenzelm
parents: 7382
diff changeset
   298
end;