­   

   

  .

          .

Contents 1 Introduction                                                                          2 Invariants  "                $            $  %      '  (             ! $  $  .

         ) $               *  '(          +                                     3 Crossing a River ! .

                    !  .                  !  - "   ./      !  0   '(        ! !                !!  "                !! . 1 $  .

  2       !! .

            !!! 3   $ !!) .

  3        !!*  4              !)  / 5 "       !*                                                                                                                                                                            1  ! 5 # # &  ! * & & 21                .

                                                                                                                                                                                                                                                  * +  # # & ! !) !* !#    .

           )            )  6  . 4 Games ) %   -           ) .

      ))* .   %': .  5   )!   0 -         ))   / -             ))             )) 7 8   9    ))! %          ))) $  %': .   )*                 )+                                                                                                                                                         5 Knights and Knaves * 6 .      ) ! .

<<                       * "  6                    *  .

                    *  7   7               * !  '5                 * ) = $                 * * '5 / '5                 *! '5   " '5         *! '(  /     / '5  *! > ? 6              *) ?                          ** "                       *+ =  .

                     * 85                        *#                           6 Induction + '(  .

    + " $  .

 .  +! $       +) 6 .

 +* $  ? . .

/                                                               .

                                                                                                                                                                                                                                                                                                                                                                                                                                         41 ) )! )! )) )* )# * *! ** *+ * *& + +                63 +! +) +) +* ++ +# +&   ! ) + & # #!      85 #* #& & &! &*    .

0" 3          + . ++ + +# +& . @A   "  .

     + .  .

                            ?         7 The Towers of Hanoi    A       $  ' /   .=B2           8         ! $  8      )              *          8 Knight’s Circuit #  0% "  #  5      #! .9  8     ! .

    #) 3         #*  / >  < #+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  &* &&   ) *         107   # & & ! * +       117     * ! ! ! Solutions to Exercises 133 Bibliography 153   .

          .

   .

          .

Chapter 1 Introduction 8             4 $     /     4 "      C    C 4     /            /   B          D E      0           / F     /    /  G4         4      /    H        .

   4     8            4             4    $    4   4            $  /    F   /       I 4  4              /   4 $  A   1        2      5     / 10  $     /    /     . /                  0     A  $                4          $    /       0                 1.1 Algorithms         /   0       0    40A    /    /      (                 (          /           "   /4    4      /   /   (  4   B  4        /  /  .

           .

            4  4        4     17  /  /      $        C4  4 41   D 9C    0 5  /     4    /            0   4 J K  x  y    L  K  z    L $  5  /        /        (       G   H 17              ?    4     I /              4            0      .

       0         0   /           /       $              G.     0        4     /      H $   4      /    $    / /       /  /        $    F    0     /     / (  C     /      ( $   /  (               /      < /     C        4         /  "  4   /  /    C4               K  L1C               /               0  $          4            . (  /          1  3  19  20         30  .   8    /   0           /        /               /      .

 .

.

    8           /           (          I     0                     4        4 $       I  /       5 Æ               .

          .

.

    1.2 ! Bibliographic Remarks $      / M6!N   .

          .

)   .

              .

   4     .      /       $  A   4      4 4               4 4             C    /      4       $       4   4 4  5   4  /4 . A     /    /         A       A Æ         8/  1        ( $  / A 4              A /  /  .             5  4 4   5  /   4         $       5     4    4  4     $       .Chapter 2 Invariants K8L  K L   /               /       1  >    / KL  K L K4L  K L $    /        0         $         /         / (  /   .     /                     (   /    $              I 4   4                 B   A        Chocolate Bars          5  <         4 8       5               /    G$          4  H   .

       *    .

+ .

 J "  0 .   4  4×3          A   $         .   .

   =4                   2  Empty Boxes '    (         4   /   (           (     4   /    (            (        /        102   ( =4  (     2 ! Tumblers                     4        4   G A  H 8  5            4   =4         I  4           .  J $  .

 4    /                    4  2 ) Black and White Balls "   A 4    /   / 4        4  $              /4   . 4   .   .

          .

        /             /4    /    $  4   /    8/         4   4           I /    F       4         4      4 ' (  /             /       I 4      /       .  /           /   A              /     4  2 * Dominoes        0    0/ 5         62 5   G A !H      /    . !J % "    I    4  (  4 5 /     8       62 5 /     4     4                   /   2 + Tetrominoes  .

   A  / 4 5 /     < $   A F      >0 O0 60 $0  80  G A )H $  /4 (          4             / 5 /     <            >            /    /      4 GH         4    4       /          / 5   .

          .

# .

1 The Solution $       0      /4 .1.   .          /           /       $      /       /     .1 Chocolate Bars        J          5  <         4 8       5               /    G$          4  H =4                   2 2.  2 2.  . )J >0 O0 60 $0  80  G H          4 $0   4       / 5     / 8  G H          4 60   4       / 5     / 8  GH  8×8     4  >0   A/ 60  .

  4    .

.

 .

4     /       /   $    KL   K L /     /       ?4 4  4     <     F  4     /        /        8        4 4     4      $       /   4 4          /  '5     /  4 4          /     .

          .

.

2 The Mathematical Solution >     / /              .     & .   (                         6         4  4  Abstraction $           4  .    4   '            /            .1.                      /            /   2.

 .    p      /    4    c      /  $   /           .

 K  L /        /   G K  LH            /      8          > /                 4   9 $            $     5 4         /    /   $         K    L            /        K04L    04       /      I                   >             5  /              < /      $       p  c          /         5  /            74    /      A     4        < /      $           $       /       8     /     /              0    "   4     / /  C    0  /   9C  $     0              G$(    0 /  4  A $     /       C/ (  4   A     / 4      C         9 $   4  $  A    (    / Æ       A $      4     . /      $  A       .

          .

 .

    $       A /       ( A  A  >      A 4     I     /    / /  F H Assignments $  (       1         /       .     /    .

  .

.

c+1 . p .       4   . c := p+1 .

      $  4         .

c := p+1 . (    5 A word of warning      . (  p−c    /     p .  K := L   K   L $  /     0   /   G    p . c+1    E   (        /      G. c H ?              /  $        0   / (  G    p+1 .      E         / 5 4    / E      / E /                . c+1 H $      5      /      /     F    /      (          (        $              /       /      /     (        8  (     C    /        / C     p+1  c+1           / p  c        8 4 p K   L p+1   c K   L c+1  $   4            /     /         /       /  /    4       (  /     . (  p−c   (       p  c H .

  .

      .

  .

 

  

  
 

  
 

.

           .

 .

  .

.

    .

    .

      .

         .

         .

    .

.

 .

        .

   .

    .

.

 

 
 

 !
 

 

  
 
"  
 
 
 

   #      " .

 .

 $ = %       .

       .

    & .

           " .

     " '  #     ".

                    .

   Æ.

(()  !  
 

   

    


$

  

becomes 

 % 

 $

   " .

   %             .

          .

.

p := 3×n . c := p+1 . c+1  $  /  /   5    (  E          (  E /                   (    4  4   m  n   4      m .      4         m  3      n  1        / m + 3×n  -  (  E      ls := rs  E[ls := rs]       (            /      E   ls      (      / (  rs  =    ( J (p−c)[p .   .      p−c = (p+1) − (c+1) . n−1] = (3×n) + (m+3) + (n−1) $    /        /4 E    /     ls := rs / /    /      E  E[ls := rs] = E . n := m+3 . c+1] = (p+1) − (c+1) (m + 3×n)[m . c := p+1 . n := m+3 . m+3 . n−1 .     m + 3×n        m + 3×n = (m+3) + 3×(n−1) . n . n−1] = (m+3) + 3×(n−1) (m+n+p)[m .  4     / p  c  $      p−c    /     p .

          .

 .

   Induction $  A      /         (      / p−c  8 p = 1  c = 0    p−c = 1   p−c    p−c = 1   4      .           5 p = s  4  s      / 5           /  c  A s−c = 1  $   c = s−1  $    /           / 5                .

  .

     $         8    /    /  (   0              4      4           $   /        <      /   (     G          <      H 8/        (       /   (              4                    /   (                  /     /     ?      / .

       8       / < 8    /    0                          (   5 G 4   <   5H Summary $       /    0        /     0        C        .1    . 4                 Exercise 2.

    /   $4       I        G 1   H   4   $  4 /            / /               1234      =4      0 /     4   2 G=J         H 2 2.2 Empty Boxes $      0 (         '    (         4   /   (          (       .

          .

.

 4    /                    4  2 $       4   D           /        4 6    u  $       F  /  4 /     $4           4      4 $           .     ! 4   /    (           (        /        102   ( =4  (     2 $  /4             8      e  f /     /        / / (     8/     / e  f  8/   A  / e  ! %     /    (   (      e  f ) 8/   /     * "            A  / f  =      A  / e+f  ?               /  (      /   (  4   /  4      /                  5   0    $      F    0J    9 2.3 The Tumbler Problem 6  4   4                /                          4        4   8  5            4   =4         I  4           .

          .

) .

.  /    /   4   u := u+2  u := u−2  . $    / 4  /        (   /   A   /        /    /  /     '     / skip   4    skip  .          /               .   u := u+2 .  4          4  G      4         4  H   F   u  8           0     K L  K  L  K   F L 8   (    5      u := u . $ 4         4      4 $          F  C u   u := u−2 .      skip           (  skip .     / 4      4 / u 2 $  4 J   0    / u  $   / u    .

u)[u := u+2] = even.u /    5 $  (even. J     true  false  8  true / u   G< 4 /    H    false / u   G   A   H 6  4 even. $   even.u     /     u := u−2  .(u−2) = even.u .(u+2) = even.u    /     u := u+2   (even.u .       4    4  4       /     /  04   4   8/              4 4     I /              4 4      $                <  04   O         4    5            /  04         .u)[u := u−2] = even. $   even.

          .

.

   * B   4           /      4   G   )       H       /               /        $  (      /   P              /     8/    4        $                   4 G=J     /   5     H .

 
+GH       81   
 
+G H 4  4  C  4 +GHC    (   =   /  4 

2.4

Tetrominoes

8     4     /  
+G H $       
    / 
  
    
   
      

        4 $0 
 4   
  
/ 5   
 / 8  
/  /    
       c     

/  5 $      
     

c := c+4 .

$  c mod 4   G c mod 4     
/  c  4  , 
(
 7 mod 4  3   16 mod 4  0 H 8 c  0   c mod 4  0 mod 4 
4   0   c mod 4  4 0  8 4 4  K c   
 / 4   
 L % /   4 K    L   

4  K c   
 / 4 L
?4      
  m×n  G$      
/ 5 
   m     
       n H $  c = m×n  
m×n   
 / 4  ,     m×n / 4  
m  n    

 / 4   
        m  n G  H   
 / 2 
?    /    
     
     
  $0 
.  4  D  4   /       

+GHJ /         
   /    
/     
   
$    /     
+GH    4    0  

    
 $    /  
Æ    
   
/ 
  
    
8 /        


 
     

 

+

$    40   $  A    0  K  L         K ⇒ L   $        m×n    4   m×n     / 4  G K m×n    4    .   KÆ L                     6    4 KÆ L                           9     4 4      /              ( / ( 4       (  $ 0      4       D  =      4 J  m×n    4   ⇒ { J c     / 4  c = m×n } m×n     / 4 ⇒ {   /   } m     / 2 ∨ n     / 2 .

m×n     / 4 L  K m×n    4      m×n     / 4 LH $  ( 4    /4   K ⇒ L      4    0    =         /   /          /  5  4    / 4 G4       /    H   4   /    /  m×n         /  5  m×n  $       J 8/ m×n     / 4  m     / 2  n     / 2     K ⇒ L   A     $    K ∨ L  KL ?    KL 4  0  K  L C        m  n    / 2     0  K(  L 4    m     / 2  n     / 2        4 (      $           A  $             4 (       /     B      / 0  4            Æ  4 /      4            $    /        K/L   8 J   .

          .

.

    8/  m×n    4   m     / 2  n     / 2  $   /              J  0    (     4 (         4  80   4     4 4 (             4 I            8      K ⇒ L      4   (     %    4       6 4     4  K ⇐ L           4  4 /    4     4   /    F  4   6  4     +G H   $            4    4  5      $  $0           4 $    4    4     5   4  5   4   4  5     5 .       $0  G A *H .

          4                /    5     /     . *J 3    $0  .   /          /    $    b      /    5 4  w      /  4  5 8  d      /  $0        l      /     .

                 d . w := d+1 . . b+3 . b . w+1 .

  /     b − 3×d − l . b . b+1 .                  l . w := l+1 .     . w+3 .

          .

# .

b+3 .  4               $0  ⇒ { /   +GH 4 4       /         / 5 4         /   5 5     / 4  5 } b=w ⇒ { b − 3×d − l = 0 w − 3×l − d = 0 } (b = w) ∧ (3×d + l = 3×l + d) ⇒ {   } (b = w) ∧ (l = d) ⇒ { b − 3×d − l = 0   . w+1] = { A /   } (b+3) − 3×(d+1) − l = {   } b − 3×d − l  (b − 3×d − l)[l . w+3] = { A /   } (b+1) − 3×d − (l+1) = {   } b − 3×d − l .      /     w − 3×l − d . b . w := d+1 .   (b − 3×d − l)[d . b+1 . ?4     / b − 3×d − l  <   4 4  <   4  $0              / w − 3×l − d 4 4  < . b . w := l+1 .

          .

.

     8/        $0      /  5     8  B  4   +G H $        +G H 4             4 8   6    4 /    5    4  = /    4                    /            G=4                       /   F  /     8  1   Æ    +G H       +G H       /     4        / $0           A 4    /            (          4             Æ      4    H . .    !"  & w − 3×l − d = 0 } b = w = 4×d = 4×l ⇒ {   } b+w = 8×d ⇒ { b+w      /  5 }     /  5     / 8 .

6 Bibliographic Remarks $   0 (   4     .2 -    /    /  D  $     /  D          4  D  / F           D  /      8/ (    4             D  (    2 2. .D $     /      4    / M-#N $       8 /    &&& .  +GH      +G H    -  9 2.5 Additional Exercises Exercise 2.

    .

          .

 .

    .

 G  JPP4444P <<PH @ @ . C/5 /    C   /      0     3   $       (  /     <<  4   8   /  /        ( $             8   4    '(   4     3  "   8 4  G    F / H      %    >   &*        @  KO  @< %   > L     % 4 &## $    /            .

          .

Chapter 3 Crossing a River $  (             /             .        / K 0/ L         .

 .

         81   5   1 5     5   / /    4 .  /            I  / /   4   0          /  1     /        $    / 4  (       <         /       ?    /  4 4   /             /   0  .

 .

        4       .

  0    (      /       4          >        4    4  /      8   /         /          4 1   4  =4         F              /  0/   /       0                   4   4  /    $  (  /          0  5   /    4    /  B              4    / 0/   C4   4     / C    (  9 =4   /    /     4                               /     3   4   4               .    4               ( /    .

           .

1 Brute Force Goat.1 Problems  Goat.2 3.                 4    /   4/   3.2. Cabbage and Wolf  /  4   /        4/     =4          /                          /  4     G 4    4     H    4/     /  4    G 4   4/ 4    H =4    /      2  The Jealous Couples $    G    4/H 4     $           4              $      D /        4  4   4/   4    /         =4            2 ! Adults and Children   /        /   $                  4  =4              2 %    0        ) Overweight    "  3     /   $    4            46    49  "  52   3  100   1 4 =4           2 3. Cabbage and Wolf $  0  0  4/0    /    0/    >      4   0/        / /    .

          .

.

   #  !   0   4          / 4      Æ   /           /  4   /        4/     =4          /                          /  4     G 4    4     H    4/     /  4    G 4   4/ 4    H =4    /      2 $     /       /   4   $     4       /    / 4    / 4  .      f G/ / H g G/ H c G/  H  w G/ 4/H  4       L G/ /H  R G/  H   / R  K     L   / L     /  ?       4 4    /    4                 .

 .

.

       .

             .

  4 /  /      C    .

             4     0   $    4          4         $    4    /        I /        . (  4  4 4         J   /     /   $  /           4       4/     /  .     8   0  0 4/0          4    /   /    /       /     4        A  .

.

   8/         4            .

.

   .    4  0       0/         8/ /       / 4     24 G (H F   /  =4        /      (0  $  5         /  4      (      .

    .

          .

$       /                  G f = g = c H          F  G g = c H $  (   4  g  c  5  F / f      5         /  4   4/  (       f = g = w ∨ g = w . 8/ 4             4        $    4  4    F   G?    4  f  g  5    / c  w  4I 4  f  g  F c  w  5   5H f 6 6 6 6 6      g 6 6 6 6  6     c 6 6   6  6 6   w 6  6  6  6  6  ?4 4         4    $    A !  D   $  .)       f = g = c ∨ g = c .

/    C  (C       .

.

             4        '             / K6666L (    KL ( $        /4 J  $  /               $      / 6666  666   . /    C       (C    $    4                /   (   K6666L      4   /     /  $   4  /         4    /                 4/     /  $             K6666L (    K66L ( .

          .

.

/0. !J -0 " 0 .   #  * RRRL LLLL RRLL LLRL LRLL RLRR RRLR LLRR RRRR LLLR .

   $  /               4    $      / 666  666 ! $  /     4/          $      / 666  66 ) $  /            $      / 66   $        4     K  L K4/L           3.2.   4 5         4   4       /              ! 8   K4 L       /                    /        16   I     0  0  4/0          < /           /        / F I /          4        /       /       0 $       /   KD0  L     4 =    (    / 4          /     .2 State-Space Explosion $   /        /  4    4  /  4  4    =4       4       /    / /       .            5        8   D        /    K   L      $  0  0  4/0      I     C  9C        /        /  .

          .

3 Abstraction $  0   (   /    /        I    /5          $  0  0 04/      (  8   0  004/             K/ L   KL   K  L    K4/L   4     4  /2 8     /       4     K L 4   4/        A       / 4     4/      $  K L       J 4  4           / K4/L  K  L .   /  K( L 4      /  G n    (   2n H .+         8/ 4             /   26   64 9 $ 1       /        4   4 1         /  8       D0         A                 $   /         210   1024  F        /  $ J    KL         $  K00 L      / /  /               A         $    /        A       B    /     /    $   /     /  0/    /    / 4    K L    4    KL            (   $  0  K0(    L     4 $  0      K ( L  4 8/    n               2n F       / 5   n  2n       .        /   /    4 (           /         5     34 0    5 F              /    40             /    0 8   5            C   /   < /    4                        2 3.       K4/L    K  L       F  2 6            4           0     4   4/      8       4    .2.

          .

. $         K L         4/ K L  /  4   /     4      =4          /                          /  4   =4    /      2 ?4            8      J $               4     $          /4                             0  /      $    0      4  /   (      Avoid unnecessary or inappropriate naming.    /              /     /           < /       $    /                    .

          /  K  L 5               .        /                        3.3 Jealous Couples @ /            /               $           /           Æ                  /  $          /          $  D0       (  (  8      /              F    /    0        J $    G    4/H 4     $           4              $      D /        4  4   4/   4    /         =4            2   .

          .

1       What’s The Problem? / 4                4      /                 4 K L         0  $            / K L     J       /  4  / /    /4    /    /    4      /  ?4     K L  K  L 4 /         4          /      /        G/      D /   9 H       4              /    Æ   /      /        $        F                    4           4            /         2 %  4            / n       2 >            4 G        /                       H  4  D  4       /  4    /      /      4     (    /       /   4      8/        G H   (    /    <  /       /     (      5  4      / 4   /    4  4      / 4   /      $  4      Æ       8       4     4 C    /       4    4  C  4  5      /             /     4   4 C   4             A      /       3.2 Problem Structure $    /       4  4         .3.# 3.        $                $   4              J    A                                  4      ( K /  L 4   A     4   /4       .3.

          .

 $    &     K  / L 4   A         /4     4 -    4   4           /       $      /               Æ   /   4  /    -        A 4    4     /      >            D   4           4  D     6 /     / I   1     4    $   4       /       4     8    .

 4   /     $    /    /   / /     4  I        /       /   /    / .

1W      4/ 4    /    4  1C      4/ 4   /    ?   4            / (     "   8     .         9 8/       4     /   4      D  $    4  4  G$  0  /   0  0 4/0   (     /0      4 $         4    0   4/    4   (   /      I       0/  4      /     FH 3. (       4    I / (  1H.3 Denoting States and Transitions .                  $    /        /       4 4                A   = 4   H  W  C     4/       $        I / (  2H  4   3C       1C.2H      4   .3.

  4  . /   4             1  ?    (           .

      .

     4    G    4/H    /         4 5       (   3H || 3W  4       4           /      4           (  /    1C.2H || 2W  4     .

          .

1W || 1C. (0   1C.!           4      4       /   4 4        $       3C ||    5 A    || 3C      4               (   3H |2W| 1W I        /   4 4              /    4/       ?      /         /       /       / (          /      4   /               $   4    P     A .1H   G       4/ 4         /              4         /   H  3H |3W|             4   8              5   4    3C ||   4    || 3C     4            /  G8     / 0 0      F    4 H      (     /   8/ p  q    S   5  /   { p } S { q }        /   5  /   S  /     p   4    q   / (  { 2C.1H || 1W } 3H |2W| 1W { 3H || 3W }             4  4           /   4 4  4      4           /  4     4        >/  4   4      /    8             "          /4   .

          .

S3  4      D  /     /     G     / H    A  G       H $       . S2 .4 ! Problem Decomposition . { 3H || 3W } S2 { 3W || 3H } .3.   5  S3      / S2     4            S1 /4  S2 /4  S3  4  4   S1 . $  5  S1     /         4     4                  /  $  5  S2      / S1     4     /   4      . >       (  4   /       $  /0     $  /           4 /        4           $         S0    5  S1  S2  S3    { 3C || } S1 { 3H || 3W } . { 3W || 3H } S3 { || 3C } .    4  (    /         $        5  /   S0 / { 3C || } S0 { || 3C } . $    3.

.

    4 4  (          /  4             /  / S3        /  / S1  8/ 4     / S3      /    4 /         /   / 4   S1           S3   /  . 4         /   S1  S2         4              /    G8            /  /  H =  4       .

          .

       5  S3     / S1 J { 3W || 3H } 1W |2W| 3H . .2H .2H } |2W| 1C. { 1W || 2C.   . T2 { 3W || 3H } .2H || 2W } 1C.2H { || 3C } .2H |2W| .2H |2W| . { 1C.               ?   / S2      /            A      /  $    5  / S2  /4 S1   /4  S3  $   / S2      4  /         5  8/                 /4 / J { 3H || 3W } T1 . 1C |1C| 1C . $   { 3C || } 1C. 3H |2W| 1W { 3H || 3W } .1H } 1W |1W| 1C.!       { 3C || } 1C. { 2W || 1C.  4 /  4     /   S2  .2H |1W| 1W .1H || 1W } 3H |2W| 1W { 3H || 3W } .2H |1W| 1W . 1C. { 2C.

          .

      4          D0     J { 3C || } 1C. 2W |1W| 3H   . { 3H || 3W } 3H |1W| 2W .2H || 2W } 1C |2H| 2W { 1C || 2C } .    / T2 4 J { 2C || 1C } 2W |2H| 1C . { 1C || 2C } 1C |1C| 1C .2H |1W| 1W .2H } 2W |1W| 3H { 3W || 3H } . { 2C || 1C } 2W |2H| 1C . 1C |2H| 2W . $    !! ?        C 1C |1C| 1C C  $     /00      00/ I 4       $    4        5  /   T1  T2  8/       /    /             1C || 2C       2C || 1C  @ 0 /       / /                2C || 1C       1C || 2C  $        0/        4      . 1C. { 1C. { 2W || 1C. .2H |2W| . 3H |2W| 1W . T1     8  / D 4  J { 3H || 3W } 3H |1W| 2W .

          .

!)       .5 A Review . { 3W || 3H } 1W |2W| 3H . G8           4 $                        $            H 3.2H { || 3C } .2H . |2W| 1C.3. 1W |1W| 1C.

 4   4          D0           /    4   F      0/    $         (      4   /           /  4        0    .

.

 5  4    A    K   L     ?    4 5   /    /   /     { p } S { q }     / 4           $  A     $ 1   /              .

     A   4  4       /   A        G(  !H    /    / A        / / B       A 4     4     /       /      .2 (Four-couple Problem) ./     4   /           0         $        / D          (0   /             3          $  /4     / .1 (Five-couple Problem) $   A D          (  /    3  4              2 Exercise 3.   4               /       %               (        .   / /       /4    J Exercise 3.

          .

3  4   /       (  / 4           /           4   /       (  /             (          =J          $      J    / /          $         2 3.4 Rule of Sequential Composition $  { p } S { q }  4  /    D0          /   /        8    !.   % &'      !* G8              /      $       /  /       /         /   /        /H 2 Exercise 3.

 .

 G $ =        4    5 / /  /     /    I  4  /   A     H        A    4            $  4       A   0  .

  p           A       q  .

 (           r   d /    M    N 4    N = 0 .   .        /      8/ S      p  q    /      pSq    /      /   p / (  /   S  (  / S       /4      4 /   q  .

          .

!+       G    0   4H    M = N×d + r ∧ 0 ≤ r < N . . 8/     S      A  /       { N = 0 } S { M = N×d + r ∧ 0 ≤ r < N } .

S2 .   /    5 I       (   /              5  $  / S1  S2  S3    S1 . S3        (   A (  S1    (  S2     (  S3  $      .

".

S2    S1  S2  /     A  pS r 1  rS q 2 .      / S1  S2  S3   5         4                 8    /      4       p     q      r    $    /     S /     A  pSq       S  S1 . $     r        / S1    / S2  8/                4      $   4  4      D0      $          3C ||    || 3C  $     3H || 3W  3W || 3H 4           A    $   F 4 /     / 5   $    /                             S1 I        /         A   S2  "           A   S2 I          / /      r       S1                     J   .

          .

   4     8            4             4    $    4   4            $  /    F   /       I 4  4    .2.5.10 } .10 }  { p || q.10 || } S1 { p.4 (The Torch Problem) .10| q { p || q.         Exercise 3.10 || q } p |5.5.5.   4     8            4             4    $    4   4            $  /    F   /       I 4  4              /   4 $  A   1        2      5     / 10  $     /    /           4  4        4     17  /  /      8       A        /       $  A         4  4       4 4   4     4           4        /     4         "            4 4       D $  5  4             $          (              4    4 4    G8 1 4               4 4     (  !)H . .   % &'      ! .10 || q } { p.      A /       4  /   /   p  q    /   / p |5.5.2.10| q       (           /   5  /  S1  S2   p  q    { 1.5.10 } S2 { || 1.5.

          .

    F 2 '      /   =     /  /           /          (d) -          .        4       2 Exercise 3.!#                   /   4 $  A   t1        t2      t3     / t4  $     /    /           4  4       B      t1 ≤ t2 ≤ t3 ≤ t4  .  /   /   4        D2 G-           H (c) ?4 /   4       4       D      .5    0/            G(  !)  H $  4       F 4 /  /        =4  4   2 2   .        /   /          /4 4 J (a) $      1  1  3   3  (b) $      1  4  4   5  =J 8     A      G4  t1  t2  t3  t4  1  2  5  10    H              4 4    =4   1 4             /      /         B 4         /     4       /     8          4    /4  J (a) =4                     /    2 G8          H =4  /      2 (b) "      /     D    4     /   4           /   4       D2 .

          .

 & ( 3.5 !& Summary 8     4   0/   4      0/            %                  /          0      0   (           /      4    4/   " (   4   4          /      I   4    /            4      < /               < .

/       /    /            4          /             %                    4               4    /   4     G 4     H          0      A         ( /      $         C /    /      04    /     4      /4           A             1    .       (        /       8  0              4   /     $                       A          4 .

          .

)   .

                .

Chapter 4 Games $       4  4     40    -     (  /               40  $          G K LH /   4               4 $    4      /             /    $          /  (        8            /       $  (        /   4          E /       4  .4  4     / 0    / 4        G     /  /      /    H    .

    4  4  K   L K%  L      5     =  4          4      / 4      4.1 Matchstick Games      .

  4     /   $4          %         /  /          $    .

 4            $   4           .

          .

         (  /       .

    4  .

.

  K8 L     /    5    G"  / (        4     4             H K"  / L        .

       )    .

)  ) 4      /     8                 4          I        /       /            / 4   /    4  /  4         / 4      4 4     /      .

    4   4     4 2 * $     /   '   4    1  3  4   (        4       1   G /       1    (       3  4  H .     4 2 ! "         4       (      G 4     4    1  2  H2 8   4    4  4     4   4            N   4  N      A(   2 ) $     /   '   4    1  3  4   .     4 2  $     /   '   4    0   .    /   / 4      4   (         /     4      1  2   $        4      /       / 3 G       /    0  3  6  9  H $        4  8/ m      /       G m      / 3 H        m mod 3    $     1  2         $           4      /       / 3  $          0   /  4              4          /            / 3  8               4        G     /    ( H   4            4    $  /4 (           A   $     /   '   4    1   .     4   4     4 2 * .

.

  m mod 3            .

       m  3    .

.

     /                4 4  . *   &  )! + $   4  /           /      1  2  3   .         /   A  .2.  4          4          4   /    /  I 4  4 4            /            4        0/           /               / 4           /    Æ       4.     4   4     4 2 # $   4  /         I /   /  1  3  4        /      1  2       .2 Winning Strategies 8     4 /  4   5 /  4  .     4   4     4 2 4.     4   4     4 2  $   4  /         I /   /  1  2  3        /      1   7       .                4        $  A         0 0  /         /     /   A $                             4I 4 (                   / 4           A      4    +  $%       .1 Assumptions .

  .      .

 $ 1       4 1 2 3  4  -.

   $ 1  4% 4%       .

      .

          .

2 Labelling Positions $  A    4  .))  ) 4.2.

.

 )J %   -  . )    /               /   ) 0 1 2 3 4 5 6 7 8 .                .

     4             / .

   / .

.

      n  4  n    2             n−1          n−2  $   /    4      /        2    4      4   = 4     4              4    4  A   /     4    /    /      4  A   /   4     4        /       $      4   /       / 4 J         / .      0       8       /     4       .  '          .     4                4  /          $    A )            /         .        4  .      1     (          0  .     4                            .

.

  /       4         / .

.

   /         A                    I /    A  A      / 4  4           8        9 =4 4             4    $     /      /       K  /       4 L   8         /   G0(H     4    .

          .

.

 *   &  )* $      /    /      /   / K x    p L  4      " #     .

 )  4    /              7        8  $          4 4    I        4      / 4       4 4      $        4  /    0 1 2 3 4 5 6 7 8 .    4     3            / 4   4       A   /     4   $    4       /        ? 4  5    K4L    6    KL    7  8    K4L    . ) J 6  .  " #               4        /   K x L    5A  8        K L G  H              A )    0    KL        /  8           /       /     4       ?(  1  2    K4L   /         0  4  4 4      ?      4  A            /    /        4 ?4  3    KL     /  3    G 1  2 H   4     K4L .

3 Formulating Requirements $    4        4    K  L           /       / 3  8       .          "      /     $              4      /       / 3  $  4       I   4        4              4      /          / 3  4.2. .

          .

{ 2 } 2 ≤ n → n := n−2 fi n      / 3 } n := n − (n mod 3) { n     / 3 } $   A   /            $  A       $  (        4  /    4      /       / 3   0< $       0     .)+  ) 4 (       =   6 n      /       $      /   4   (     /4    J { n     / 3   n = 0 if 1 ≤ n → n := n−1 .

.

        0    C      K 2 L  C      / 0  .  "       K if 0 fi L   .

          / b → S  4  b   0 (       S                   (        4     true     (    8/     true       /     8/  /      true  (      8   4   if 0 fi               0      4 / 1 ≤ n I       n := n−1  KL         4   C       n := n−2 C  KL     2 ≤ n     /             /       n = 0  $    /          K n      / 3 L $        A         /     /       / 3                /      4      /        /   4      / 3  $  /  /   5        /   4 I   /0     n mod 3   $  A/     A   4     / (  /   4      /   4      / 3   !   .

   .

     .

  .

   .

.

  .

        .

( .   .

.

 ((.

   !           .

  .

    .

.

           .

 ! (          .

.

     .

          .

.

  4     /  4 /       4   I             .  5   n mod 3        4  n      / 3  8   4                 losing  $    G   4       H  /     losing  $  4            / losing  . *   &  ) 8    /    4  n     / 3             4  n      / 3.

 % /      4     4   /   /4   A  {        }     GH  . { 4       }   4  {   } 8    4    4 /          4          4     4     /4     J  '      .                4   .  4    4             4  0 8/    /    4         8/                 4 @ 0  /       4    A     4  /           1     /   4    .   4       5 G    /    /       H 5 G      H             4      /     < 4         5 4 4         /     .

          .

             H H G=H                       /   (   2 4. /      /      5  /      4    /      M  2  Exercise 4.)#  ) .       4        0    4           /   / 1   M        $    M      A(    .                A       M  0  $                  /   ?(       M  1  $               ?4     4  4      M  2  4      4  D  3        2 8/  1               4       M  3  G31 4    "             H $         M  0  1  2 G     (   0  1 H           A .1 (31st December Game) $4      $  4     4    ! 3           '  /   (    F  /         4    . (    A       .3 Subtraction-Set Games   /            /     GAH  /  I       m   4  m     /                  .     4   4     4   /     4            =J          /  / !+*  G !++     /   H 4             /   8                         4      /     3           H G'H         /   (         /          G.

.

     /          .

   .

          .

 ( /               4    4    4  J                 /   8   4        {1 .. 4}  .M}  %  (            4     . &   +& ) )& $    4  D    (  /     I /       1   M               {1. 3 .         4     4   0  .

             /       . (  2           / 2   1 I  3  4  4    /        0  ?          / 4  .H    G6H 8           4     4  4     /              /        . /           K  0 L      4              K  1 L      4     D           4  0   4 0 0      4 / 4       4               /   /     4      4  /      /      $         $  )  4    4    < /       6  $   4         4  4 4        4 G. (  /  3    4 4  C   3       0     1      2  8 Æ    D       4 /     .

1 2 6 3 . 0 $  6 % 1 . 3 6 . 3 4 . 4 $  )J .H  6 G6H . 4 5 . G.

4}   . /     {1 . 3 .

          .

*  ) .

3 11 . 3 13 . G. 1 9 6 10 . 7 $  6 % 8 . 4 $  ) J . 4 12 .H  6 G6H .

(M+2)  s.(k−1)  W. .  W.          4    2M   $   /   j  k  4 M ≤ j < k < M+2M  4   s.06  4   /   20   4 8 /        - 4        / 40  4     2M+M   . .(M+3)  .k  ?4     2M F 5  /  /  M    5    5  s.  k    M  W.(M+1)  s.   k   W. .(k−2)  . .(k−M)  "   5  s. 3 . /     {1 . 4} "     4    (       J    )  "    )  )  4        / 4      / >           4  4     / .k  8 /4   W.   /     /       {1 .j = W.k         5  W.k    5  W   /   k   4 .j = s. 3 .   (             .k  true / k   4   false  4 . 4}  4          4             r  /      /    7  8/ r  0  2         > 4    4  $  4      1  / r  1    3   / r  3  5     4   / r  4  6  $        / 4           (       /   0   4   5    /         4      /     4        4  G /   4   4 H $  /4       4                     A        6    M  $  /        M  .

.

6} H   . 5 .2        /   8   2  5  6       G$          {2 .k    8/         R    /     k  W.(k mod R)  Exercise 4.k 5 W. $   4         4          /   k  /    / k       s.

          .

 )!J   6 .3 . )!  4   /    8        D   $  4             /    /4 $    5 1    A  5 25         /    /         /    / 4     /   I /        / /          /    21 22 23 24 25 20 19 18 17 16 11 12 13 14 15 10 9 8 7 6 1 2 3 4 5 . &   +& ) * (a) .  n  0 ≤ n < 22    4     / n     4    (b) 8/      4      /         /   /  / n     4     / n     4    @/           4 4   / 1   4      2 Exercise 4.

            /    /4   .

          .

  4    4     .       /     A  I         /              4   F /    $          / 4  I     4 /            8   4    4  4  /       /              /4 .           / 4       4    4    / 4           (c)   /      A  4      4 '(  4  2 4.*  ) (a) 6         G$           5 $  /   5       H (b) 8/   4    .4 Sums of Games 8     4   4  (      /          4   F  $   (  /         )       /   .

 ))   (  /    / 4   '       4                       8                       /        $      /                        4  /     8   K L /     4              /   4           /                $       K L /          :( 4  K:L        /    K(L           I      F  /  (   / K:L  K(L    /       A ))   I 5   0 /           )     4      4    =4   /    A ))  15 F    .                    /      /                          /     .

          .

 A 4      Æ   4 D   4  /      3     /     /    4. &  % ) *! O M N J K F L G H D A k h I B f C j g c E i d a e b .1 Symmetry A Simple Sum Game .  4     (  /    / 4        4  /    4       /           .      /   /      0/        8     4  4     4  /    / 4   . ))J   -  $  /            4        :( 4  K:L      /      /    K(L      /             (   / :  (         11 I      /   4    15×11 F  . A       F     G     /  /  H /   F 5    4    /               .4.

          .

*)  )   /     > 4            /          4       4        $       K L / 4   /          J   GH  /             /    8         4         4              4           $    4                8 5        4   4  /       Æ   4    /     8/          /   C       4  /     C      4                $    4 /    4       4    4  m  n      /      4  8         5   /        0  $        m = n = 0  $            m = n  $       .      /   4   (     /4 0 5  /      { if m = n ∧ (m = 0 ∨ n = 0) } 1 ≤ m →   m 2 1 ≤ n →   n fi . { if m = n } m < n → n := n − (n−m) 2 n < m → m := m − (m−n) fi { m=n } $  0    4   m        1 ≤ m     n        1 ≤ n        /        $  /      m     n         m = n /   /      .    4  m = n        G     1 ≤ m  1 ≤ n H   4     4  m = n   5     4      /        (    /    4        m = n  .

          .

2 m=n } Keep It Symmetrical! $       ))    (  /      /  I   4            4 /    /   4   4    /    0  .4. &  % ) ** $    m = n      /   4      '5 m < n  n < m  8      m < n  4 /   1 ≤ n−m ≤ n     n−m       /    4 n     n−(n−m)  A  m       /     n := n−(n−m)      m = n 4  $   n < m     $  /4 5  /          0  D  /    /   4  ? 4   4      4        $    (0       /   I        losing         5     { m = n { m<n ∨ n<m if } } m < n → { 1 ≤ n−m ≤ n } n := n − (n−m) { m = n } 2 n < m → { 1 ≤ m−n ≤ m } m := m − (m−n) { m = n } fi { 4.         4  4   0    4        $    (  /   4         4 =     $     /     /    The Daisy Problem      16         $   4          4 D   $  4     4        .    4  4     4 2 -             n      /   4 1  M D   G4  M  A(    /    H The Coin Problem $4          4     $         /    /    $                           .

          .

*+  ) .    4  4     4 2 G!. )*J  16 0          $  4     4            .

  / 4    /     F      4 J   / (  4       M      /         /   /   N      /         /      4  M = N       /         F / (  /                    8/       4        0 2 ?   / / K L       4 J     .4.  /               D/  42 4. (  / K  A(  1      4     4   4              J        /        4     I              4       A  F  /              /             .3 More Simple Sums 6                     ))         /                    K       /    G4  K  A(   H $  F  /       4   4  8/  / m  n      /      4     4    m−n   4  K < m−n  "5     m = n         . H .

          .

{ m mod (M+1) = n mod (N+1) } if m mod (M+1) < n mod (N+1) → n := n − (n mod (N+1) − m mod (M+1)) 2 n mod (N+1) < m mod (M+1) → m := m − (m mod (M+1) − n mod (N+1)) fi { m mod (M+1) = n mod (N+1) } G?J 4      /  / 4             H 4.r H 4  l       /    r             F  D   I          GH     .4. 4    )      4  4   0    4         M                      /      /    M+1  0  $  /   / m       m mod (M+1)   4        4    $        40    K L 4     /         m mod (M+1) = n mod (N+1) . &  % ) *         9 . G M    (    /         /   /   N    (          /     H $         8     4     0        A       4   /4               /4     { if m mod (M+1) = n mod (N+1) ∧ (m = 0 ∨ n = 0) } 1 ≤ m →   m    M 2 1 ≤ n →   n    N fi .4 The MEX Function $   / A K  L   K        5L           "          / 4              G l.

          .

*#  ) l := l  G/   l  H    /     GH   r := r  G/   r  H        $     A 4 /  L  R    /       0     4     G l.r C        C  G l.r C  $   { if L.r H / L.r ∧ (l      ∨ r      ) } l      →  l 2 r      →  r fi { L.l = R.r = R.l = R.r  $  5 J 4        /  /2 8   4 4  4   /   /  L  R 2 $     /  4  4        A  .r H     (  4  L.l = R.r } .l  R.r H / L.  /   A    5  / 4 A L  R   /  4     /     5  J  .r H     /      (  4  l     /   /    r     /               L  R  5        4  /    C  G l.l = R.r } . $      4  /  4  C  G l.l = R.r C              4  C 0  G l.  l         / l  l    /   L.r C $   { L.l = R. .   G l.r   ?       /        /   /       / 0    / 1      5   $   /      /     5  8/ L.l = 0 = R.l = R.l = R.r H / L.r }   4  { L.   l  r /        L.r  F      .r H /0  L.r   .l       /  r          / r  r         R.l = R.l = L.

          .

4.r  R.r } .l < R.r        /   4  R. &  % ) *&   L.r } if L. )+  4   (   /  /            $           I 5    4      (      0/   /   $       $       (   0   5  (         4           (   G   /   p    q         / p  q H $    .r < L.p   A          n      $           G / p    q / mexG.l →  l fi { L.    4 4 5  J  .q = n   .r →  r 2 R.r < L.l  = n  $   5   A / 4 A   /  L  R     0  K (L /  $    A /   /    /4 6 p        G  $  mex  / p   mexG.q = m  K%(L    / K   ( L  / /     /   (   /   p           (  /   (   /  q  4       / p  4.    m    R.          A ))       / (   .r  = m    /    n    L.     m    n             G / p    q / mexG.l = R. .l         / l    l     L.r < L.r        / r    r     R.5 Using the MEX Function .l  $  4   A     /     4             4  L.l < R.l < R.l = R.l  G 4H { L.

          .

 )+J %( ?  $  (   /                  (   /        A                (   /    . )  4      $       /   A    (   4         (   8     4   (       2    /                 4   (   0  1  ?4   4      6         K>L $    4      (   / K>L  F /   (   / KL $     G 3  2 H    4               KL 4       (    K>L $                /         4 (   F / 2  $  A         /      (    5          /  ?     /     /   /      4       15  /   /     11  /              (   /   8   / 4      .+  ) 2 1 1 2 0 0 0 0 0 1 0 3 1 2 0 0 0 0 0 1 1 2 1 0 1 0 .

          .

 4     4     / : m 4  K:L   / K6L G/ K/  LH  KL G/    H  m      /         .    4      4     .4 H "          4       /   / 4    2  5  6       "    (   /         -    /     (   /   / m        H "    4      / 4   8   /   1  2          8       2  5  6       8                 /              $    4  4    / F              /  J     /      /       /         6/ -    -  KL  4    2   2 * * 2 + & 2 ! )! 2 $  )!J .    K2L . )J "  (   $         (   2    26 F      D    G     /   4H / 15  11            165  $          F %    4    < /         Exercise 4. &  % ) + 0 1 4 5 .

          .

+  ) 2 4.5 Summary $          4     40    $      /         .

6 Bibliographic Remarks $  40   K.         Æ         4 4 ?     /    4      (   G. .L M"-# N    "4  -      /     $  ! 3     G(  )H    / M3.     4      (   /    / 4  H 4. #   .N   .   4 4       A    /    A      /   0/        4    4   0/       /        $   /   K L / 4   ( A   4    (         /  4      A   /    / K L 4   /      4 4         A  /   K (L /      $   / ( /        F     4       K L / 4       0/    -        40(   / %    4  4            8                " 0     >  /            /4        /     /      4    /   /4             /  (  (  / K  0   (LI     /          / 4   Æ        4   4 %(   4       -     K? L     (        K 0-L   /   0  ?   404          /   .

          .

       4   2 ! $         "     K  "       L .Chapter 5 Knights and Knaves $   /       A      /    1       $    4   /  K L 4  4       KL 4  4  6 <<    /       /       4  4 4                  $              C     n     2n F                 C  "      4 /        8        <<   (      /       4  4        5.    /       /  2   .1 Logic Puzzles =        /  00 <<  8               B   /    4           $    J K$              8    L $     (a) "     4            2 (b) "     4          2         4 /    B   /   4            .

       +!    .

2.  5         4             G      H2 # B 4     4       /    "     B    P 5    /    .    P 5             4 4   /   / /        4   4 4   5.+)  .     5    2 &       /     4          1   /         / .  5          4     "      2 * 3  5   4     4         + .  / (  4     (   m2−n2     4              / (m+n)×(m−n)    /    / m  n  .  5         4       2  .   .2 5.    m2−n2  (m+n)×(m−n)  . )   C  K       4    L .1 Calculational Logic Propositions $    4          4 (  4      .

 n−n = 0 .      $4 (  / (    < J n+0 = n ."   4 m2−n2 = (m+n)×(m−n) .   . $   /        /   64         5 4 (  $   K  L            4    4     KL            /    /        (  .

          .

.

 (  K  / L          5J (m+n)+p = m+(n+p) . 4    /  m  n  p  G" H       4 (  4    0  K L C      true  false  '(  /  (   K  L G4     true  false     4   4  KL /H  n = 0 G4     true  false       / n H  n < n+1 G4   true /    n H 0 (         $            4      $    (          0    4  / (  m < n < p  4     4    0  %  / m < n  n<p 6     4      4 /    I        /          6     /       .      K/  n L $  4  /       4         .    - +*  / 4    4     /     n  .

.

C      KL KL  K/L            "        .

$              /   4        $   A=S . H '5         /  C /  A    -/ .   .   .      5 /           / 4           4 /  4   5.2.  6 < 4   / +)+  +  4  4   A    /    C  5 /     (   . . . ."   /        (  /   4          G/ .2 Knights and Knaves '5 /       <<              4         4  8/     /        K    L    true  false                         K       /L      /   A      K    L          S. .

          .

 (  /   K       /L   A=L . 4  L      /     K       /L 8 4              /                 / . $  1    9   1    A       4   4 (        4         8/      P 5 Q         5      / A = Q  $       4  KL /         4            4    > 4     4  KL .++  .   . (     5 K    L   4 4 KL  A = A     5 K    2L  4   KL /           G A = B H  4 KL $   1    KL  KL        / / A = B        5       / 5         /  << /          A (   /    4            4             1    A = B      /    1    B = A   5    I  /   4   4 4      ?                / F  / A  B  $      / 5 /        (   / 4          5. .2.   .    /   K8    L 4   A=A .3 Boolean Equality '5 C    / C     /     .

&.

.

 $   x = x 4     G  H / x      .

  $   x = y       y = x  $      .

y G4    A(   /    H $           .  $   / x = y  y = z   x = z  .x = f. / x = y  f   /    f.

"  .

"  '.

  .

   E(          4   / '5    /  8   /  4      true  false  .  '5     .  4  /      .

          .

.

 (          J /  x  y  z  x + (y + z) = (x + y) + z  x × (y × z) = (x × y) × z .    - +  /   4   /       .   / 5 4   /   D        / 5 4     4      / 52 8 5     2 $  4           5 1     /   /     /     /  4       /         $  (  (p = q) = r D 1   4  p  q  r        5    $   (    5 /   . 4   ( I    (     /4 $  E( / 5  (      (p = p) = true . $       J /  x  y  x+y = y+x  x×y = y×x .   .  p  q  r             p = q 4 r / 5 $   (p = q) = r   /        p = (q = r)  8         4  / 5 8   4      4   5 /      C          $   /   p  q  r  G*H [Associativity] ((p = q) = r) = (p = (q = r)) . B               / (p = q) = r  / p = (q = r)       B          / 4  (p = q) = r  true    / 4      / p  q  r  true  8/ 4 /             false  (p = q) = r   false  $    / 5    4/   /           / (  .

          .

                      4               4         /       4    4        /  /4   /    / B 4  /    . . $   /  p  4     G     H  /  p  4        / 5  J p = (p = true) .  4      /            6     A       * .      4 5.   .4 Hidden Treasures .2.   4   /    K8     5        L2 6 A  / K      L  G  / K       L $    1    A = G   4     A = (A = G)    true = { 1   } A = (A = G) = { 5 /     } (A = A) = G = { (A = A) = true    / 5 / 5 } true = G = { 5    } G = true = { G = (G = true) } G .+#  . $          / (     K true L /  (  /   / p = true  .

          .

.

2.    5 Q     L = A  $      5 K8     / Q     /  /4   / /1 5      / Q    1 L ?          / 4  L  8       4    4             4             4  8  /   5    4       P    /   5     P = A  8    /   (   P    5    A 5.    - +&  5        4  KL /   / /    /4  KL /     /    /4   4    4    6 Q    5    $   4 4         5 4  A = Q  6 L  K     /  /4   / /L $  5     L              5 $   4 5   L = (A = Q)   L = (A = Q) = { 5    } (L = A) = Q .   5   4       4   "       $       4  A  B  C       G     "H     .   Q    4 5 $    4 4  C          * ) Q = (A = C)   "1    A = B   4 4   C = (A = B)    5 / 5 Q = (A = (A = B))   A = (A = B)  A  B     5     K    2L =              / Q  4   4         Q = {  / /  5   .5 Equals for Equals '5    /        6 <1 J / 4 ( 0   5  (      /     = 4     (  /    / 6 <1          /       "  "  K          L .

       }    .

 4 / (  0 ≤ m ≤ n  =        %   J     0 ≤ m  m ≤ n  8   4   /       G  m   4 4 H %  0  4      /    0 ≤ n  $                /   0   8/    4 m  n  m < n     m ≤ n  4 4 0 ≤ m < n  4  /   0 < n  =   /     (      4       /      /          /     8    / 5 /   4     3 4  5        (  /   / x=y=z /      . A=C = { / "1   C = (A = B)    / 5 / 5 } A = (A = B) = {   / 5 } (A = A) = B = { (A = A) = true } (true = B) = B } true = B = { B .3 Equivalence and Continued Equalities   /      A(    $  A       8/     ⊕    G   (x⊕y)⊕z = x⊕(y⊕z) /  x  y  z H 4  4 x⊕y⊕z 4  / /   $  (           /     /   %     (    I 4     / x⊕y  y⊕z    4       8/         G   x⊕y = y⊕x /  x  y H           /            (  4     / u⊕w   /  (  u  w  8A(    /  /   . 5.   .  .

                   .

 $ + %  $ × %   )      .

.

   .

   .

          .

 5  x = (y = z) .  p  q  (                (  p≡q≡r .      4  (       K ≡ L          . !'       !'         5 /  / x  y  z 2 >  4   K L  (x = y) = z .  D     4  4 4  x+y+z 2 $  4   /      G/ (  true = false = false  false      A   true           H $           D 4         / /     8 4   /      x = y = z     4   x = y  y = z I  4    /  5  / (     5   4        /   (     D   G/    H       C/  C    4  5           F  $           4 F     5 /   C     K = L 4     /   5            K ≡ L 4        (    4 4  p = q  p ≡ q  .

 C  (p ≡ q) ≡ r  p ≡ (q ≡ r)  4       C 4    (  p=q=r     %   C  p = q  q = r C  %    .

.  pn  5 4    . . . . = pn     / p1  p2  ."   /   / p1 = p2 = .

" .

 .

≡ pn       /     (  G  4 4           F H       (             . . /   / p1 ≡ p2 ≡ . .

          .

  .   .3. % 4        K ≡ L       K5LI   /  4   4       4      / 4   5 $       5   A (    E( G* H [Reflexivity] 5. Examples of the Associativity of Equivalence $        / / (     F  /     / 5  Even and Odd Numbers $  A (     /4   /     even    G     (  4       / 4H m+n   ≡ m   ≡ n   .1 true ≡ p ≡ p .         m+n   (  4     / m  n      . 8 4  / 4 /  4                 /     $  / 4        m+n   ≡ (m   ≡ n  ) .

     / 5     / K m+n  L  (      /  4     /     (         / F    /      F     .    (m+n   ≡ m  ) ≡ n   .         /     n     m       / m (  4  n     4 /           /        50   p ≡ q ≡ r   (  4      / p  q  r          / F J    GG m+n GG m+n GG m+n GG m+n     H H H H     Gm Gm Gm Gm     H H H H     Gn Gn Gn Gn     HH HH HH HH  $   /   (        /   $   /     /   4  K m  L  K n  L .

          .

 !'       !'    ! Sign of Non-Zero Numbers $   /     4           . $      C4        / x    4       y (  4  y  C    K/ /L /     /  5 5. 0<   x  y      x×y   /    / x  y  5 8/    / x  y  F     x×y       x  y  0<     (   x×y   ≡ x   ≡ y   .3. (       4  (      4J  K5  L  K  L "  5  G 4    4    /       H  E    .   /                 / F          8  DA  /         x×y   ≡ (x   ≡ y  ) .2 On Natural Language %          4   5 /    I       / 4    / 4 F                      /  /  /     5 %       5  K/   /L 8      5 /    A     0  G ≤ H  0 G ≥ H     A  K0   0L   $      (      /       4     /   /  KL  KL    KL          / 5      GK8/    8 4    LH $  5   4 A              ** 4       /      5  I 4 5 KL  4       ?         5  $     (     5  K       4  5          5         L     /           9 $  /            /  5      G       H   4             /       $           4   .

          .

         2 $      0  .4 Negation "   /4  00    $   4     ?   K     5 8     L .)  .   .      4       / (  &J)*  J       4  1 A        J9 B    4  4    4  4 4        F  4 &)*  J 8 /   4 /        /   /       "         4        /        4 4    4   $   /                  /   $        KL       F   5.

    ¬p = (p ≡ false) .  J    / KL ?      G       /  4 (    H                K ¬ L 4   A(     8/ p    (  K ¬p L    K p L .     p    4  ¬p J G*!H [Negation] ¬p ≡ p ≡ false . G.  /    A /        4J (¬p ≡ p) = false    4 /  /   (  8      / 5     4          5     4   4      J p = (¬p ≡ false) .       /      S  4 4   A ≡ S  4  /     J A ≡ B ≡ ¬A . 4 / K = L  K ≡ L     (   H $      /   (  8                 /     /  .   .

          .

  /         4    A  /    (     4  4        $  (  p + (−p) + q + (−p) + r + q + (−q) + r + p   .                ? 4 G*!H    4 F 4 $  4 G*!H  D  4        / 5    4 /  /  5   4          P    / (  4 4   / ¬p ≡ p ≡ q ≡ ¬p ≡ r ≡ ¬q . ?4 4   G* H  G*!H        /    / K p L  K q L     G   H 8     (  4   true ≡ p ≡ false ≡ r . $   A  ¬B  /4J A ≡ B ≡ ¬A = {    } ¬A ≡ A ≡ B = { 4 G*!H 4 p := A } false ≡ B = { 4 G*!H 4 p := B   } ¬B . . . 4  G* H  G*!H  $         /    A  ¬p ≡ r .                 / K p L  K q L      $  4  ¬p ≡ ¬p ≡ p ≡ q ≡ ¬q ≡ r . .  *      00    4    J A ≡ B ≡ ¬A .

          .

5.   A  q + 2r         / p  q  r      / −p        / p       F          $  4 4 G* H  G*!H        A   4      4 5 I    4 4 4      4    (  / 4   4 4      /   ¬false = true J ¬false = { 4 ¬p ≡ p ≡ false 4 p := false } false ≡ false = { 4 true ≡ p ≡ p 4 p := false } true .   . l := n+1 . $    /     /       / (p ≡ q) = (¬p ≡ ¬q)  .n ≡ l        $      0      $ %  . ¬l . 8 4     /            $   /       even.     /         0     G   !H            /   /   /         8/ 4  n      /   l     K       /  /   L   /          J n .+  .5 Contraposition       4     4     /     4         G*)H [Contraposition] p ≡ q ≡ ¬p ≡ ¬q .

  .

.

     .

 (    .

          .

 * H             5 $  5         /   0      5    0    4  5 ?4   col      /   5         G true /    false / 4 H  dir              /  G true /  0  false / 04H $                  J col .(n+1) ≡ ¬(even.n ≡ l)[n .n) } ¬(even.(n+1) ≡ ¬l = { even. ¬l] = {  /   } even.     (even.n) ≡ ¬l = {   } even. *J %     $  4                     0 (        E    4    4  5     4  /   5      <      G .   . l := n+1 .n ≡ l   true  8 4        /  5     /      (     /4     5    5   4     5   4 4  G A *H =4                   90◦   /  /  8          2 8/  42 8/  4  2 .n ≡ l . dir := ¬col . . ¬dir $   /        /      col ≡ dir .             /    <      4     even.

          .

   .5 (Knight’s Move) 8     /    1   4     4     /        4   /          4      8×8  / 5  4             /    0/  /  0      0      4    5       (    =J =4      2 %      /   F       /      /   5  4       I /   4   4        2   .#  .     /   (  4   5       4                4  5             $        / col ≡ dir                     8 4   /        90◦              5 ≡     /   0 4   / 4        4  5  /   0  90◦ . * J 8 4       Exercise 5.

          .

/ 0  5.6 & Handshake Problems 6    /   /    0   .

 .

  $    (  /        J                  1          /         4     4         "   4 4           /    $         .

  I   .

      .

&.

.

 8   K  L       /  4   C    C      4       / G8   .

$    /       /  x  y  ¬(xSy) ≡ ¬(ySx) . 8 4 x 1    4 y 5 y 1    4 x  ?4    a    4    b    4  $     a      4 b   ¬(aSb)   b    4 a   bSa       5 / 5 4   ¬(aSb)  aSb  4   /   .   K0E(L    0    4    .     0 /         /  / 4  H 8   K  L     /  4   C    C      4  5     4   .  5   4   G H 4            /   6  (    5  /     /    0   4         /               n   $      4   n   =4   0E(          4    .         4 4 0  n−1   $   n       0  n−1  $   / K4            /  L  K         /  L 8        0         n−1   $    /    0           4   K  L  S     4  x  y  /    8   4 xSy    K  x    4  y L  D x    4 y  $      / K  L      /  x  y  xSy ≡ ySx .

          .

 4          F          F .7 Inequivalence 8    00        /   *)      K  F / /L $     /   B = A   ¬(B = A) $    /        K     5 8     L    /4    4 ?   4 4 / K = L  K ≡ L       (    ¬(B ≡ A) = {   4 ¬p ≡ p ≡ false 4 p := (B ≡ A) } B ≡ A ≡ false = {   4 ¬p ≡ p ≡ false 4 p := A } B ≡ ¬A .  /        1 2  "        2     .#  . $          4      /           4     4             /   ? / 4      0E( /    0      .6 =         81    Æ         /          J K  L        K1   L      /   G    4/H               =   4/     >    K L    4             /0 / 4    =4           1    2 2 5. (  / 4    K  L      / /   K 4  L 4              G     4     4            H =4 / K  L      K L       6 K  L K L      0E(  Exercise 5.   .

      .

          .

      / 4  J (¬(p ≡ q) ≡ p) = ¬q .     /    p  q  G*H [Inequivalence] ¬(p ≡ q) ≡ p ≡ ¬q . ? 4   / 5           ?  4   / 5       /       4   /     /  $  A       J ¬(p ≡ q) = (p ≡ ¬q) .1 '   # . $    ¬(p ≡ q)   4 p ≡ q  $      .

" .

 .

G .

  .

q ≡ r } ¬p ≡ ¬(q ≡ r) = { G*H 4 p.    4  4    .q := p . r } ¬(p ≡ q) ≡ ¬r = {   G*)H 4 p.q := ¬(p ≡ q) .q := p .q := p ≡ q . r } p ≡ q ≡ r = {   G*)H 4 p. q ≡ r } ¬(p ≡ ¬(q ≡ r)) = { A / K ≡ L   4  } p ≡ (q ≡ r) .     H 85     J (p ≡ q) ≡ r = { A / K ≡ L   4  } ¬(¬(p ≡ q) ≡ r) = { G*H 4 p.

 .

" .

 .

p ≡ q ≡ r 4  / /  0  ?        4   4   p ≡ q ≡ r  p ≡ q ≡ r  5   A 4 (  4  4   5    4 5 J         .

  .

    p = q = r       .

.

  !" .

          .

      .

          .

r } p ≡ ¬(q ≡ r) = A / q ≡ r { } p ≡ (q ≡ r) .9 .#  . (p ≡ q) ≡ r = (    A / p ≡ q { } ¬(p ≡ q) ≡ r = { ¬(p ≡ q) ≡ p ≡ ¬q } p ≡ ¬q ≡ r =    / 5    4 G*H {       / ¬(p ≡ q) ≡ ¬q ≡ p 4 p.   .  /   /4 G?           Exercise 5.q := q.8 4        (        P  1   F H (a) false ≡ false ≡ false (b) true ≡ true ≡ true ≡ true (c) false ≡ true ≡ false ≡ true (d) p ≡ p ≡ ¬p ≡ p ≡ ¬p (e) p ≡ q ≡ q ≡ p (f) p ≡ q ≡ r ≡ p (g) p ≡ p ≡ ¬p ≡ p ≡ ¬p (h) p ≡ p ≡ ¬p ≡ p ≡ ¬p ≡ ¬p 2 Exercise 5.

   ¬true = false 2 Exercise 5.10 (Double Negation) .

  .    /    ¬¬p = p .

          .

11 (Encryption) $  /    5        (p ≡ (q ≡ r)) ≡ ((p ≡ q) ≡ r) .12 >    /        4     .  5         4       F  2 2 5.8 Summary 8     4      <<      5  C   5 /  C     /      '5          /            / 5 '(  /     / 5        F       /      << $    / 5    Æ        /    (        =4          (  /   $  / 0   /    <            K 0 L                 KL  /    D     F   $    /         KL  KL       4/  $  /    5 /        4       & 1      / $   .2 & ( #! 2 Exercise 5.        $       b /    a         / / b       a ≡ b  $            c         $             a    a ≡ c   4   /  b              4     b   /    a  2 Exercise 5.

3   4            .

.

  .

.

 $ .

 (%      3    .

      .

 (  " .

     !" .

    .

  " .

       1          .

    " .

   .

     .

 4   .

          .

 M.  8 $  ?  >/ $  2L M #N $      4    /    <<     /     (  -R1         1 /       $  (  /     / 5      /  <<    - .      /     4      / D  GKLH D  GKLH /40/ GK/LH     GK /LH  M !N  M-&!N   .     64 < G     K>      /  L M$*+NI $   /   H ?   / 4          /  '.#N . 3D   4             G  M3&NH $   /    <<     1  K.#)  .   .

          .

       .Chapter 6 Induction K8 L           0  5            /         /      $      4   4    K<L /   /     . (           /    4      /      I    /            /     <      /        5       <   0 4    C   0  1  2  3    .

 4     / < 0  $        /                  G$   /    KLH   4  4 4   /       n     / < n+1         / < n  $        . /  0  4     . 4   < /    /       5   /        =   4   < 4         4   .

1 Example Problems    /4          8   A   <      /  8             (         n   Warning  #      .  4 4      / < 1 I 4                 / < 1 /   4      / < 0  $  4 4 4      / < 2 I 4                  / < 2 /   4      / < 1       .  4     / < 3       / < 4    6.       4      / < 0  .

            0 0     .

   .

.

  .

               .

       #*    .

              Cutting the Plane    /     4      /     (    4 / /       A + 8   4           /   4              4      4 D         G        4      /      F H . +J    .#+ /       /        /  8          B            .  "  Triominoes  5   /        / < 2n×2n  4  n      $   5    ".

 +  4    /  8×8  4  5  >          4             5 4 G0   G.  >  5         /        60    /    5 . +!  4     H H ?J $   n = 0         ! Trapeziums  5  4  /  2n /      n    /   5  $    5      0    <   /   5   A +)  * .

.

     .

    0 1 2   .

           .

 + J $  ./  !"  # .

   . +!J $  .

     A +   4              4 G0  <   A +* /          n  2  H ? 8     n = 0    ) Towers of Hanoi $  $4 / =     /  <<   ##!    . S     ' 6      % " $  <<         4           4         A(     >   A /         /   41  -   ( /    / F <     / < G A ++H $     4     /        /                         $  1  4    4             /   A /     .

          .

 +)J  .## /    .

 +*J   A +)                       4 4     9 "            $     4          G.  / '5 $ .                        =4       /    0   .

 .

      H   .

          .

/.

      #&    . ++J $4 / = .

  6.2 Cutting The Plane       /     J    /     4      /     (    4 / /       A + 8   4           /   4              4      4 D         G        4      /      F H .  4    /    4        4 D                  .          /       /   K<L /      $            K         / L $     4    4 4       4     <  C     K L /    C  4    4 4       4     n+1  4  n           4       4     n  C        C  .

          .

& /    $   4     <    $    /                 4         /   G        / D  H .       4        /    4      /      F        4      4 D         $            .

 +   (  $       4   A          4   5     4   /     $      F  /  / /     4         /   / >    /              '4  D    F  $      4 4  /              /   .   . 4         4      $  4    /   (   4I   /  4           (    /  . +J "   .

    4   $               /  /  0  G         4    0H    /   ?4          /    4  6        .

    G     /   4             /    /    8  D       4 /     H ?          /   /   /   /      8         /               /            $    /   /   /  G       /  /     0 /  H 8    /   /      G       .

          .

/.

      &  1   4 /  H     / D       /   /      /        /        F . +#J "   . +#  4   F    (       /          /      .

        /      0   =4  F     2 2   . $        /     G     4      4    H $          8             /     4     4      4    /   $       0 0 '         (   A                   $    0    4 $    /     /   G    4 H    A $   /    G4    A 4    (  H     A . 4        K/L   4    K L     A $       A        / F 4    1  $  A      K/ L  5        A  Exercise 6.1 "              .    5        2 =4        ( 4      $          4     /   8      /     4    /  /       /  /   2 .

          .

& 6.3 /    Triominoes     (  /                  +       /       5   /        / < 2n×2n  4  n      $   5    ".

 >  5         /        60    /    5  4             5 4 G0 H   $     /   K<L /   /               n  .          n. $     4  n 5 0  $      < 20×20   1×1  $      (   5 $   5             5   8  0      59 $     4       ?4   4    / < 2n+1×2n+1  .        .

    4 4  (             / < 2n+1×2n+1 / 4         / < 2n+1×2n+1      4   / < 2n×2n     4 <           /   6     /      .            / < 2n×2n 4   / A     5    .

       .

      >  5    $  5 4    /   /  0 .              / D  5   /       $             D  /        4  A +& ?4                 5 /    0    0/   0   4   >   /        2n+1×2n+1     4   Exercise 6.2     <       + 2   .            0/  G8/                        H $   0/       / < 2n×2n / 4   5                5     0/     4   $    4    /     0   0/   0   4   ? /   5           .

          .

 +&J $  ./ -  #  &! .

4 Looking For Patterns 8   +  +! 4   4          /   K<L $       4      K      LI K L          K8 L    / (    (      /     /  4    4  / /    /    /  (  /           "  34  /     /           /     /     /   4 8             .   8    $      /  0 $   5  4    A   0     4         D  /        $              /  0 4   6.

  64 /      /       4  4            4 4 8   (      4  4     I                    /         / 8  .

       / / 4 / ( 4 4                  4  4        8   4   / ( 4        / 4          /  / ( 4 ( .

         /      81  0  /  /     /   /      %.

 .

     4     D    .

 .

 / ( 4 -00/   / 4 /         G-    /  /  D I A       /   4         .

          .

    4     / 3(n+1)          / 3(n+1) + 1  3(n+1) + 2     4       3(n+1)   $   4        1  2      3(n+1) − 1  3(n+1) − 2   $        / 4   3n + 2  3n + 1                     4  =      4     3(n+1)     ?4      3(n+1) + 1  3(n+1) + 2     1     A   2                    4     3(n+1)   $  4 4 4      =      4     3(n+1) + 1  3(n+1) + 2   4  $          /   4     A   D          (  4      /       / 3    .&) /     H  /            )   (  /  0        / (           )  J      /   / 4    4      4   '(      4       4 0  3  6         4 1  2  4  5  7  8    4  $            J        4      /       / 3   4        $    D       /    D   =4 4  /     D                4  8      4    K<L /   /         /         /     3   4           K<L /   / 0  1     0    K<L /   / 3  4  5    1     $            / 3n          / 3n + 1  3n + 2     4  $   /      4  n 5 0    / 0           A       4            / 1  2     4                       ?4 /       4       / 3n          / 3n + 1  3n + 2     4  .

          .

6 From Verification to Construction 8     (    /   .5 &* The Need For Proof . # % 6. +  4    4  n  1  2  3  4  ./  . +J "    $    /     1  2  4  8  $         /  /   n   2n−1  8   D           n = 5  G.      4   AH 8        /   16  4   25−1  =4 / n = 6      /   31 9 G A +H ?   n = 6    A   4       4      5        = 4         n = 0         D  4     C  1          20−1 0             9 $    5 4              5    n  F / 0  $   /     /  /     /                     n 5 0 9 6.           D     A 8     (  /  /4            % D      /I    D        / /  4   /    $        0 (  /  / D    n         /  /                 D    $        4       /  /     $  5   4         2 .

 4 /  @A        D 4   C           /     .

          .

+ n3 = 1 2 n (n+1)2 .. . . + n4 = ? . +J "    $   n = 6  $    /   31   26−1       4   /       A  / 1 D   4 A            /  8              A      0     /           /     $         /         /     /  $    4   4      /  /    /   k  4 /   A n     404 /      /      / 1   n : 1+2+ . +n = 1 n(n+1) . . + n2 = 1 n(n+1)(2n + 1) 6 13 + 23 + . .&+ /    . 4   4    (  /    /      /         (      4 / A J    5 4 /   4  4  4    /   4    49   / (      4       /  /    /   4  4 /   A n   14 + 24 + .. 2 $4   (  /       (   /   12 + 22 + . . .   .

          .

.   /     /  /     /   / 4           A/     n     . + n0 = n .// # 3 4       & =4 4   2 @A        /                 4  4      /   5 "   4       4     2 "   4       4                k27 2    9 "    0         $         / 4     00           4                0         8         /  /    $         /                 /    $          31  0  6   4               /         / m 5  1  2  3     /   m  4 /   A n        n /  m+1  G$   /   A n     5 /  / n     /   A n 5     /  / n      /   A n     5 /  / n H $     A     G/0/H    m  0 J 10 + 20 + . .

      .

.

.

Æ .

+n . ..   P.  $         5            4 4      /  / 1 + 2 + .n   1+2+ .n       S.n = a + bn + cn2 .0 = { A / P }   . D      5 /          n   a + bn + cn2        Æ  a  b  c  =  4      . .     S. $  P. + n  G   4  4    4 /    /        8/         4  $          H . ..

          .

n + n + 1 } S.n  1m + 2m + . + nm H      .(n+1) = S. .0 = a + b×0 + c×02 = S. + nm     /  /      m  $        J             n 4  m+1  .n   $  P.&# /    S. .     /      4       a    Æ  / n0   0  ?4 4   b  c  $   4           0 ≤ n  P.      /         4   /    S. ..(n+1) = b(n+1) + c(n+1)2 =  /  /        { S.n + (n+1)m G4  S.n + n + 1 = b(n+1) + c(n+1)2 =  J P.0  0  S. 2 2 '(  /                (  1m + 2m + . .   D       /   A n     5  n  4        1+2+ ..n = bn + cn2 } bn + cn2 + n + 1 = b(n+1) + c(n+1)2 =   { } cn2 + (b+1)n + 1 = cn2 + (b + 2c)n + b + c ⇐   Æ  / 4 / n { } c = c ∧ b+1 = b + 2c ∧ 1 = b + c =   { 1 2 =c ∧ 1 2 } =b .n   a = 0  { $   S. +n = 1 1 n + n2 . .(n+1)  S.(n+1) = A / P  a = 0 { } S.0 = 0 G   /     /   {  <H    } 0=a .

          .

     / 5 )./1 #+  5   &&   /   5    Æ  .

. J 8    /    1 + 2 + . + nm 2 / m    1  *  . + n      4       /    4 4   5  1 T T  T n  n−1 T  T 1   T n+1  2    4  n T $     4 4  J n+1 T n+1 T . .   /       n    / n+1 4         1 n(n+1)  =4        /   1m + 2m + . . .

.4 "       4   /   / 4  m   n          /4   (  G/ (  m  1  n     m  2  n  3 H /     /   4     4   4        4    4          $  /        4 4       8                 /     2 6. . + n2 .               .7 Fake-Coin Detection $   /   ++      K31 9 " L .    5 D       /  / 10 + 20 + . 2 Exercise 6. + n0  12 + 22 + . . . Exercise 6.3 .

          .

 4    /      4 4  C     4      C    3     J          /                $     4 n        3n F     $        4         /   ?4   4   m  / 4      /       $     1 + 2m F         4   /  J K 1 L         I  4    K 2 L 4    /   K m L    / G           H $     4 n       /    4     /         m  4  1 + 2m = 3n  %   /     m  /      (3n−1)/2            /    / 4 n   . n 5  0    D    I           / 4    .    /   D       4               4    $  4   (3n−1)/2    4  4 4   (         /  4     5  .7. D     (3n−1)/2  / 4      /              /   /  G 4             H    n   .          4  4        .               K/L        KL  KL       4  4   K/L    F 4    KL  $     4      /         A   /  /     ?     /        I 4 1  4  4        K  L $     >/     /       /     / > /  /                / KL            K   L   6.1 Problem Formulation . /      4      /   /     <     . n 5  1  4 4       $            G  (31−1)/2 = 1 H  4  4  4        /   /            4 2 > D    4    .

        .

          .

n + 1        /   4   $  (      4    /   A     $          / 4  4      8/         .(n+1)     n+1   "   A   8       /     /                     $     4    /         /     4     5 >   5  /              / 4   /    /          / $   4        A  /       /      "  4              c.n    /      $     c.n  ?4 c.n = 2 × c.(n+1) − c.        A   c.n     n   .(n+1) = (3n+1−1)/2 = 3×((3n−1)/2) + 1 = 3 × c.n   (3n−1)/2     4       /  /  (   /   c. <   4            0   / (30−1)/2   $    n 5  0      Induction Step ?4 4           n    < .n + 1 = 3n .n    (    /    4   /    / 4 n   8    4            C      F  4 c.7./1 #+  5           4    $            4 /   /  /  (             n   6.2 Problem Solution > /  /         /        /   n     The Basis .(n+1)  4   4   H .  c.    4 4  A  /  /  (   c.     c. $      I         /    4 4    G        4         4         c.(n+1)  c.n + 1 .

          .

n  .n  /      $     4    /           /           4           1   8   49 8/         4          /             /   4   / 4 3n   / 4  4 4       3n     c. /      /           c.                   /  $                    8/         4 4               .

.

                      .

        /4   l1            /    l2                 h1           /    h2            $ 4    /     4 5       /     /   5          $   l1+h1  l2+h2    5 .       K    L 4    /     K   L 4    /   /     4             4      The Marked Coin Problem 8   4                   4  4       F    $  4           /      / 4      K    L  K   L '(   /     /        "      4   4   n     /    3n          8/ n 5 0       4      /  $   0 G n H          /  .       4    /         4    4 3n+1   8   A           /              /      8                              5J 3n    /         3n     /    3n        $      4 F 4  4     4             .           5 3n  ?4 /               / 4          /                        "    4    4       l1        .

          .

             5   /  /      $  5                 4         /              /    / 3n  4  4  4      $     4        4      / 4   I         4 /   4       The Complete Solution $          0            0     $  /   A /    / 3n+1      3n         4       5   /        /             /      /   /4  (   8/                  ./1 #+  5   !    /      h2              /   G          5 HI    h1+l2     /  " /              h1        /      l2               l1+h2     /               4 5       /      5  3n  4       /     $      5    h1+l2 = l1+h2 = 3n  $  4 l1+h1 = l2+h2  4 /   l1 = l2  h1 = h2  .

  4    /       8/         /                        /                 .

  4          /                   8/                                                /   .

  4                         /   $       0    4      /   (3n+1−1)/2   /4 3         / < (3n−1)/2  (3n−1)/2 + 1  (3n−1)/2  .

    A     /     4       .

                          3       /         /4J   .

          .

      4     /     ?        .) /     8/                           0    G H           8/         /           %        /   4   (   /        K   L %            K    L         0       3n    8/                     %        /   4   (   /        K    L %            K   L         0       3n   .

                      U    J            .

5         /  D      D       4  4   (   /     ". /     /  $        /    / F   Exercise 6.

        4   /    4     m      2×m      /   5  D  4       /  D   3m  G=J /       3m+1  D       3   / 3m  D H "  / 4     5  D               D 2 2 6.8 Summary 8    /        0    $     /            /    /   K<L    /  K<L / (a)   / K<L 0    (b)     /    / K<L n  /   n                 / K<L n+1    .  D  4    F 4  8          D     B  5    4     5  D  .

          .

     /  $         4 4      D      /       $            4        /             A      6.9 Bibliographic Notes $      /0  3D M3D& 3D&N       / 4   . * ./6   .

          ' .    .

+   .

       /       .

      4  4    /      >  /       4  4  I   $4 / =            I      /  /    /       4 Æ              / /  /           7.1.Chapter 7 The Towers of Hanoi $         $4 / =    $             (   /         A       / K L     0  $  $4 / =     <<    5 Æ    4       0  8      4 /    A  =4                  /      8   4           /    5   J              /   5  .1 7. S     ' 6      % " $  <<         4           4         A(     >   A /         /   41  -   (0/    / F <     / < G A H $     4     /        /                         $  1  4    4      .1 Specification and Solution The End of the World! $  $4 / =     /  <<   ##!    .

           .

# 1  7 % 0          /   A /                         4 4     9    . J $4 / = .

           /4 >        A         $   /              .          / 0 4 >  0                        1  .1.                /      (    4   .  7.2 Iterative Solution $          $4 / =              (  $ /     4                /   %  /                  4    4   .

    $    /          /  8/      /                4   > 4          4     .

          .

1.

3 WHY? .1.    &   & >                  C  D                   8         /       (                  $     4   /           0    4        00 0   $ (     /    4 0 << $             0                  /       /    0   8/    4 A      4 3   4        (            C 5 0 6 0    7.

              4   0  4       8/         C  4  8  9C        4 % 4    4 / 4 4      /      A  /     /     $    4 4    9 8 4 A      /      $        /  4  4 4        /      7.       4     4   n  /            4 4   n+1  /    = 4    9 $       / 4                 4 J  %    n  /    /    4  (   0  /           n   4     4          /      .2 Inductive Solution "            /       6   4       0               M  /    A       A  6               " G6 4           H  /        .      /   0            .

          .

 1  7 % 0  %      /   " $       n  /    >   4  (     /           n   4     4          /    $   4         A          $  4                   A  /        4                G   " H 4         (         $        4            /  5   4   A  G$                    / H $       4  4            /    $     /         .

          n       / M−n    8/   /   M−n         n      5              /        .         $       4             n  .      / 0         8   Æ            A        $           A         (  M        .               /   $        / 4         4    4         4    4 /        /   $4 / =      4   n  /      (      d  4  d     4    4 $   /            / 4        A  /    $                ?4 4          .

   4 4   n+1  /          d  4  d     4    4 .   4           / 1  4 4          1    .  /            d   /     G       4                    /       /H 8      n  0    5  /       5  8    / n+1  4     4     /    n    /      /  4   .

          .

1.

d = [ ] Hn+1.d = Hn . Hn .d    5  /  k . 4              n         ¬d  $         n+1    n+1     4   /              d  $  /4               $   A Hn.    &    -    / (               / 4    . d          k /         d   $         5    [ ]     5   [x]   5  4 (     x  $      / /        5  Hn. d] . [n+1 . ¬d ?         H         /   5 / Hn+1.d    /   4  4     . G$        n+1   /    =4          n       n+1        4   n+1  H . ¬d . d   4  n      /  k       d  d     3    / 1 4  1      3     true     4    false  0  4   $   k .       n         d        ¬d        /  4      /          /     G /        /     H            n         ¬d  $   n+1         d.d    4     n    0 0 /            d  /4    /         /     H0.

 .

 (    4 4   H2.cw }   .cw = {  5 n.             4/   0  5     /       $  / /       I         K L            /   $         4         $4 / =   /    / n C 4        /00  4       / H     .cw  G.  cw  aw    4    4     true  false       H H2.d := 1.

          .

aw] . 1  7 % 0 H1.aw] . [ ] = {   / 5  } [1.aw .cw .   (       H3.cw = {  5 } [ ] . [2. [1.cw] . [1. H0.aw      4 8/    4 5                   / F       $    (  /   5     / n = 3  16       / n = 4  32      $                9 $           .aw] .cw] .cw . H0. [1.cw] . H1.aw .cw . 1.d := 0.cw . [ ] . [ ] .aw = {  5 n. [2. [1. [2. 2.aw] .aw } H0.aw] . H0.

 .

   A   To  T1  T2  =    4 /   D  (  Tn     /  / n  .        $           G  H (               $     /                 /   5  /     (  $    /             9 Exercise 7.d     /   5  Hn.cw  6 Tn.1 $    /                /   5  H64.d  3    A / T /     A / H  GB   A   Tn.d    / d H .

      /  /     / F   Exercise 7.  D      n  2 .     4 4     0     4     / n         4  4  .       4               /        2   .2   $4 / =    .

          .

3  (             4           /          /           4             4       $   4           /      41  4    4  4  4    4 =4     /    4               /       .d        K n+1 L      K n L  K d L      K ¬d L   even.k ≡ d    G   4   4 /H $      0 5  /    /        ** .3 ! The Iterative Solution                   8  4   J   A               G      /      4     4H               4            8     4  4 4       /      Cyclic Movement of the Disks 8     4  4        4       8 /  4       .N ≡ D . d  4  even.d     even.(n+1) ≡ ¬(even.k ≡ d     / G/   k .(n+1) ≡ d         .d H 4        / n  d  6       N  D  $  /   k .    /  / Hn+1.1    &   7.  4              4       /   /   $      /   k . $  /  4         /   d /  k    A  /   5       /     4    0           4     0           4   @ 0 /   5       /     4    0           4     0          4   8        G4   0 H            D / N           D / N   Exercise 7.k ≡ d ≡ even.n)     / even.   even. d      5  Hn+1. d      5  Hn+1.

          .

 4       D   /                4             (    << /    Æ             /  4    /       4/     4       4    /             F      /   << .d A     6    5  /    . 4 4    /  /     5  Hn.) 1  7 % 0        >   (   4       /        /   3               2 2 Alternate Disks .

ks ∧ ((ks = [ ]) ≡ (k = 1)) . [n+1] .d) = { A } alt . 4 alt. [n+1] . diskn . >     alt.  /   4   $  A           4        I          /   5   0        4     . (diskn .d = diskn . [k] .ks /   5  ks    4   $  5  /       4  4   diskn. ¬d) ⇐ {     /  5    . ks) ⇐ alt.d)  $  /      n  $    n = 0          5        .d         A   /  /     Hn.d = [ ] diskn+1.d  $  /   A / H 4 J disk0. diskn .d       6   5          4    diskn.           /  5   4    /      /  5  ks    k  alt. $  /   J alt. ¬d .(diskn. ¬d . ¬d .(diskn+1.(ks .

       }    .

5 (Coloured Disks) $   /    I F     F 3     4                    4                     B             2 7. ¬d = [ ]) ≡ (n+1 = 1)) = {           A D   /4   / diskn /     } true .n ≡ d ≡ even.4 Summary 8     4   4             $4 / =             $       . $  (  /            Exercise 7.  4      (      2  4        G=J $     4   4           B       4               /   1    4    %  /   /         4  n                even.4 >            /    8      /          /   ( 1 A           /         $   /    4              4     4   I       0  9 .   (  4        4             00 0   4         4        /   41  $  4           /  .(diskn .k ≡ d  /     d     k 4  n       d H 2        4    Exercise 7. ¬d) ∧ ((diskn .1 & ( * alt.

          .

N   .+ 1  7 % 0 4      /         /        n 0    $   4   D/          / $   4   /        / /   /   5  /   /             /     $       4    J     /   0 0       /     G      1 0   H      /            /      /   /    G  4    4H  7.5 Bibliographic Remarks 8/      /   $4 / =     / M&N  / /     /     4     M6#N $  /   /      M.

          .

Chapter 8 Knight’s Circuit $                 B    0          4 F             $      A  7 1   /    $   A  5  /    4   7          5 /      5 (         5  4       $        /     I              (  (  /       7   /4   0  C  0   .

 .

  /    5       / D 2   /  /   16  5       / 8  G A #HI /     5   4  6     $       /            /4 6 /          4    4      50       /         5 (             $  7 1         /       /  .   =4    64 5    I    64       /  5 .

   4     /        $  5                7 1        A      G4 5 <      5       H $      /   4  4    (  8.  7 1     Æ         (   /               .1 Straight-Move Circuits .

           .

     4     /         /         / 52 .   /  4  2 $    A 4   4  /  5     5 8    1 4         /   4   < C  /  5      5            5  ( I        5     D   61   /     /  $       5 <    G$         7    (   H . 8    .  4   4              /    /       G=J      .1 (a) .# 2 .       8         /    D 4   2 $  4      1     B      A   0             A        /              I             8×8                  5     /       4          0    /    2 $          5 (            5  K L     2 8      /  4           /4 (  8     /4 Exercise 8. #J 7 1 % 61            4      /  0     4     /      4   .

          .

2  & +9    &      /  5   F  5 > 4   4         /     4H (b) . D       4   $            5 $   4    /  /    5    0        8        <  ?4      2m × n      2p × n    2q × n  4   /       G$   4       A        / 4          /   /   H $   0/  /   2p × n          0/  /   2q × n  "   0    /   4  . #  4       $  4 <      0/ /         <    4 4  /  /   4   $           /     G>/       /         /      /         H ?4         /    /          <  /    0/   0/        4         A #! $          .               0    /       . 4   / m          0    /   / < 2m×1 2 G 2m×1      / 5I     / 5  2m H (c)  4            0    /  2×n  /  G H  / n  G 2×n   4 4  4  n 5H 2 $    / (  #      0        /     < 2m×n  /    m  n  $       2m        n  G m  n   0<           (  /     5H    0     4    4      < 2×n  /  n  $     4 4       0    /  2m×n  / m     n         m    2×n      /       $         4      / < 2m × n  4  m     1        /   4  m     1   2m × n       4  / < 2p × n  2q × n   4   p  q      m  p+q 5 m  .

          .

 #)  4             4 /  6 × 8  '/0 /     /         0    /   2 × 8  $               <          4  A #) Exercise 8.  2 .       4        0    /   n 2p 2m 2q . #!J       4     4 . 8    n 2p 2m 2q .2     4         / 5       "  3×3  8        0    /   5     5 G A #*H 8          0    /   5   /    5 =4   0    /    /     / 5 C  5 D     5 / (    0/ 5C     '(  4       4            0    /    5      /  <   . # J "   0    .

          .

2.

 & '    . #)J   0    /  6 × 8  . #*J  0    G 4  H /  3 × 3     /   5 2 8.2 Supersquares 6  4     7 10      $        (  4  4 4      $  4             8 × 8       4 × 4       2 × 2 5  K0 5L   4  A #+ 8/       7 1    A  4  J +  .

 .      K L 4        5I     7 1    /    /   5     5        4  <    /       .

        4        5I     /       .

          .

    . 8    . #J   GH  3 GH 7 1 % . #+J "      4 × 4  /  5 7  /   5      /          5 8 A #    /    5        I     /   7    4                          0110 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 11111111111111 00000000000000 1010 1 0 0 1 0 1 0 1 0 1 0 1 1010 1 0 0 1 0 1 11111111111111 00000000000000 00 11 0 1 0 1 0 1 00 11 0 1 0 1 0 1 0 1 11111111111111 00000000000000 00 11 1010 1 0 0 1 0 1 0 1 0 1 0 1 1010 1 0 0 1 0 1 11111111111111 00000000000000 0 1 0 1 0 1 1010 1 0 0 1 0 0 1 1 0 1 0 1 . 2 .

 ##  4      /   5 C   0/  5C    0 4  <  4 $             . (  /    0/  5            0/  5      0   5 >     /    @   E        ( 4  <  E     < ( G$         0 04  0 0  I   <      0(00  4 4   40(00 4H   .        4 4       . G H  /    5         .

          .

2.

h = h. y) .v = h.c = n .h = c = h. & '  1111 00 00 0011 11 00 0011 11 0011 00 00 11 0011 11 0011 0011 00 0011 11 0011 0011 00  ! . z H 4    A  /  5  /         . h      / A E         E    4 /   5 .v .  4 A       2 × 2 5 $    /   4     0    '4  4   skip        = /   4  n G  / K LH .     /  /               G#*H n. (    . ##J    /    0/  5 6    v     / E      /  2 × 2 5 G v    / K LH       h G  / K <LH     / E    4 /   5 ?4   A(         /    / (  v .h = c.x = x. $    5 G#!H G#)H  G#*H   4   /        /      G       x /4  4   y  z          A x /4  y      4 z C    x . .n = x . z) = (x .  4     4  <   4    1800             $  I G#)H v.         E    4       E    4        $   v.v .   5     2 × 2 5   1800         c G  / K LH     $    A / c  G#!H v. (y .

          .

9 $4            2 × 2 5            90◦      4         4 8/     /     2 × 2 5  (   !      4   F  /     /   2   .v.6 "   40       4   F  / (  4   x  y   $       / 4  /        / n  v  h  c  G.x .v = h. 8    v.h = { v.h. ) 2 .h. x = x  4 x := n n.h.h = c } v. (y .      /   / x  y     {n.       / E  5      H .v. G8        43   64  F   $  / 4        / 4H 2 Exercise 8. z) = (x .c.c}  G#H x.y = y.v.c}  G##H x . y) .h = { v. z .n = } n . 8 4 E         1800         E  <          G? 4      0   4   A      $   /  A(   / K/4 L /    0     5H Exercise 8. "      / x  y     {n.h = n } { n .

          .

 #&J 6   5       /  0       # $  4      .3  * Partitioning the Board $  A  /   /     5   A   4    7 10         /    5    K n L $      A/  5   5    n  v  h  c 5            5 .2       8. #&  4 4       4       0/ 5   K n L 5 $         K v L 5      /    K h L 5   D      K c L 5  5 /  4        /         5   64 5 /         / D  8 A #&   F    A     /   5 $4 5       5       /       7 1  G$   4 5 /          /       7 1   4 5 / F      /       7 1 H 11 00 000 111 00 11 000 111 00 11 00 11 000 111 000 111 00 11 111 00 11 111 111 111 000 000 00 11 00 11 000 000 v 11 c 11 v11 c 11 111 111 111 111 00 000 00 000 00 00 000 000 00 11 000 111 00 11 000 111 00 11 00 11 000 111 000 111 n 11 h 11 n11 h 00 11 000 111 00 000 111 00 00 000 111 000 111 00 11 00 11 00 11 000 111 00 11 000 111 000 111 000 111 11 111 11 111 111 111 00 000 00 000 00 11 00 11 000 000 00 11 00 11 00 11 000 111 00 11 000 111 000 111 000 111 v c v c 00 11 000 111 00 11 000 111 00 11 00 11 000 111 000 111 00 11 000 111 00 11 000 111 00 11 00 11 000 111 000 111 00 11 000 111 00 11 000 111 00 11 00 11 000 111 000 111 00 11 000 111 00 11 000 111 000 111 000 111 00 11 00 11 n h n h 00 11 00011 111 00 000 11111 0011 00 000 111 000 111 00 11 00011 111 00 000 11111 0011 00 000 111 000 111 .

          .

 #J    / /  K0 L  K04L   $   0                         $               4    . #  4  4 /                      4   C    4 K L         4 K L   '(        A   K    . + 2 . 4  /  %           5 /   0  $  A            $  4       (    KL 7 1  G/    A # /    / KL    (H    4 /     /                  4  . (  4             K0 L   / /   I   4        4     K04L   .      0   04        /       . 8        /             0    /   / 4                 4 8   4      0    /  4 × 4  ?4  K L 7 1   K L 4        5 /    $   4     0    /  /   /  / 5      8 A #&         /     5    /     5    /     5     /    4 5 . #  4     4 0   04    / I    4    G     H                G      H .

          .

 (        /         A #            G        4   0    /    5        0/  /   H =4    0    /    5      5       /     4     $  Æ     A               0    .  K0 L  K04L   $      4              4        0         A #  /  K0 L   $    /            J      G H        G H $      /   4   4   0       04               4   0    $   /   (     Æ  /             0         .2         L 4 4       4         >            /     / 4   5I 5          K0L   K40 L   1111 00 00 111 00011 0011 0011 00 000 111 000 111 00 11 00 11 111 000 00 11 00 11 00 11 000 111 000 111 00 11 00 11 000 111 00 11 00 11 00 11 000 111 000 111 0011 11 00 00011 111 0011 0011 00 000 111 000 111 00 00 00000 00 11 00 000 000 11 11 111 11 11 111 111 00 11 00 11 000 111 00 11 00 11 000 111 000 111 00 11 00 11 00 11 111 00000 11 00 11 00 11 000 111 000 111 00 11 00 11 00 11 000 111 00 11 00 11 000 111 000 111 11 111 1111 111 111 0011 00 00000 0011 00 000 000 00 00 000 00 00 11 00 000 000 11 11 111 11 11 111 111 00 11 00 11 00 11 000 111 00 11 00 11 000 111 000 111 0011 11 00 00011 111 0011 0011 00 000 111 000 111 0011 11 00 111 00000 1111 0011 00 000 111 000 111 . #J .

          .

 # J  K0 L   K. 8    . # 2 .

 #!    4           $  /  0              / 4    E         $         0 4    8/          G          H        /      $        /    A #!    A $       4    / F             4  4  (    G8             H "    /       .10 "   7 1   /  8 × 8        0    3     /  8 × 6  8   4           /      2 Exercise 8.11 .L      4            4             4        8      7 1   /   <    F  /               $         /  8 × 6    /    Exercise 8.

          .

    G0     H      /   G      H  /       0/         /  I    4              A -         8 × 8   6 × 8    .2        & . #!J    / "   0% "  .

.

.

.

. *    .

 .

         .

4m × 2n   m  n    m ≥ 2  n ≥ 3 .12 3 /   / < (4m + 2) × (4n + 2)   5   (2m + 1) × (2n + 1) K L              / G H 5   0             (  #       =4        7 1   /  / < (4m + 2) × (4n + 2)  4   m  n    1   (  (  #  $       /  0    /       /    5 G  (  # / 4    H $  /       . G$    /       /  8 × 8    /  6 × 8                    /    0    8/    Æ         90◦ 4      /     H 2 Exercise 8.

          .

 8          4  C       C  4         5 $        A #) 11 00 0011 11 00 00 11 .4 Discussion 8      /       7 1        Æ      4        (  /      0   . #)J  / "   7 1 "  / (4m + 2) × (4n + 2)  >  5    /  0            5 $         4 "     /    /  6 × 6  % /  /     /  6 × 6  8       4        A #)   Æ     D  I        /             '(  4     /   6 × 6     7 1 0  /   / < (4m + 2) × (4n + 2)  4   m  n    1 2 8.! 2 .

          .

2 5    !  $    4               0  C     7 1         0           $    /   .

         /   < /  / 4   7 1   (      #* $  7 10     ( A    /        4   4      4  $  n  v  h  c     /  (  /  K LI     5 /          (  /  K5  L    /          5  / D    (  /       K5  L $  7 10         /    /     K= 0"  .   4        (        $       /     4       7 1      $              /  8 × 8                  $        A  /   K L  KL   0    /  5          0     >        /                 7 1      "   4        / 4           /      4   /                       5  4            7 1   /   4     / 5 $        4      < (2m) × (2n + 1)  /   m  n  G$                H .

  L 8        = 0       0  K L G 4 / KL 4 KL     H    5    A             (    /       = 0           /   /     K?.

0  L    ?.

0              / A   Æ  /   $             4         G/ (    5  /   5           4        7 1  HI 4 /    / ?.

0       Æ      .

          .

6 Bibliographic Remarks     /     7 1        /         /   M% U  4 .! 2 . 3D M3D& N =   /  0<         /    0        (  # $  4   /  0       3  %  M    N      / K  L % 1     /    D 4  / K  L    /    3D1     / /  G4   H                $    (  # 4        4 / /   / %    .N   A 7 1       /  0 0        /  4  $   /  5    7 1        ' . 8     4      /    K" (  L           /          5/ 4 Æ         8.5 Boards of Other Sizes $  4 8.

          .

1 1233      6 k      /           g      /        8 k  g   5  0  '                k  g  4 5 $       1234−1       =      /      8  /    p       / p−1   2 2. p−1 .p := m+1 .2 6 m  n  p      /  D  /   $               m.Solutions to Exercises 2.n. "   . n−1 .

.

 .

p−1 od 2   .p := m+1 .  4 ( J do m↓n↓p = m → m.n. m−n  n−p  p−m  8        /          G8     F              2 H      /  F  /       4  G   <  4H            4     4  F  4              /      <  F  $          /    D    /              /    $       D          D   /      5       D    8/         D        4  D  / F  "         /  D  /         /5 4            /  D  . n−1 .

       !!    .

3H . 3W |1W| 4H .3H . { 5W || 5H } 2W |3W| 5H . 2 3. 3W |2W| 5H . 2C |2H| 2W .3H |1W| 2W . |3W| 2C.3H { || 5C } .   /    4      J { 4C || }   . { 3C || 2C } 3W |3H| 2C .3H { || 4C } .1 { 5C || } 2C. 2W |1W| 1C.3H |3W| . 4H |2W| 2W . 2C |3H| 3W . { 2C || 3C } 2C |1C| 2C .3H |3W| . { 3C || 1C } 3W |3H| 1C .2 . 2W |1W| 2C. { 4W || 4H } 2W |2W| 4H . 2C.!) &    !"  3. J { 4C || } 1C. { 2C || 2C } 2C |1C| 1C . { 5H || 5W } 5H |2W| 3W . 5H |3W| 2W . /       A0      F            /  . { 4H || 4W } 4H |2W| 2W . |3W| 1C. 1C.3H |1W| 2W .

          .

       G!H (lH = lW) ∨ (lH = 0) ∨ (lH = N) .  (b)            G*H M ≤ lH .   .     N    2  M        / 3  N/2  G$           /   /    2  4      /    3  6  H 6 lH      /      /  $    /          rH     N−lH     lW      / 4    /  $    / 4        rW     N−lW  . 2W |1W| 1C. 1C.3 6 M       /      N      /   .3H . 1C |3H| 3W .&    !"  !* 1C.3H { || 4C } . $                      /   4  8   5  /            G8/    0 < lH < lW  0 < rH < rW  8 4   4          /         8       H ?4 4           M  N    (a) $       /   G)H M < lH .3H |1W| 2W . 4H |2W| 2W . { 1C || 3C } 1C |1C| 2C .3H |3W| . { 4W || 4H } 2W |2W| 4H . { 4H || 4W } 4H |1W| 3W . { 2C || 2C } 2W |2H| 2C . |3W| 1C. 2 3. 2W |2W| 4H .

          .

!+ &    !"  .

  GH     G        M  N H ?4   GH          / /    ?   lH = 0  /  /    G/    lH = 0  (         M < lH  /    lH = 0         M      H     G!H    J           4  G+H (lH = lW) ∨ (lH = N) .       /     > 4      ?     /00    lH P lW    .  4  /   J lH = N   (lH = lW) ∧ (lH = N)      N/2       / lH = N /      N/2  /    /  $   G H   /    8/ (lH = lW) ∧ (lH = N) /        lH = lW   0      G$     G+H           lH H $    5   / 4                        / lH       1   G)H       /   I 5 G*H   /               $  G H   /    8   4       /    G H   ?4   G H        /    /   00/   lH P lW      lH = 0 /     lH     lH = 0 /    G  4       M  0<       lH = 0  >              0   (  / 9H  4  4 J               8/        /    lH I  /    M < lH  G/ H        /  $  GH   /    8/  4          lH = N G   G+H     /  4           lH = lW H $   lH     M < lH  /  /    /        /     /  /    $  GH   /    8   4       GH   /    8     GH     / GH     /00     G H    I  0 / G H      00/    GH            GH  G H   $                      2   .

          .

4 5    / 4  2      2         "       / 4   3  4 C  4 4C    G"  5  /      /      8/    /   4 4    D      /   4 /      D     4  4  /     5   4 5   / 4      /     5  C       /  .&    !"  ! 3.

 .

          /   .

/4           H $   4  /    4 4  J              $   K   4 4   L   0     1  2 G  4 /H  4  1  $   3  4    2  .  1  2   $           t2 + t1 + t4 + t2 + t2 . 8/   4 4              1  4       /     8           / t2 + t1 + t4 + t1 + t3 . G$      2   1     1     4   1     1   A  1  3  $    4   2  3  4   /    $     /      /    H "         A      4  t2+t2 ≤ t1+t3       4  t1+t3 ≤ t2+t2  G$        /      J 4  t2 + t2 = t1 + t3         4   4 H         4   A  4 J (a) $      1  1  3   3 J   1+1 ≤ 1+3    4 4      $       1+1+3+1+1   7  (b) $      1  4  4   5    1+5 ≤ 4+4    4 4      $       4+1+5+1+4   15  G$      /   4 4     4+1+5+4+4   18  2   .

          .

2 $  A  J .             4 $           /   /4  4    0     ?       .              F  H 8 3          0      4 0     0   G$ J $  K L             $     4     /   4 H $   /   0     0      4         0     4   8      4     3   4    ?      4  8 >    3     0               4        0             4  $      4       /  $   4      I 5  0         $      0    %   4 I I   0         4  $     ! %       %      /     4 4 / 3    ?    ' 0    %         .5 6×2×3×3×1   108  2 4.!# &    !"  3.   0        .    4  .1 H ?     3       ! 3      $   /         ! ?  G       / ? H           ! ?                ! ?  $   /         ! >   8    4          /     $       /        /   (   .  > 4          (  /         /     0 2 4.

 0 $  6 % 1 6 2 . 5 6 . 5 10 . 2 4 6 5 . 2 3 . G. 6 8 6 9 .H  6 G6H . 6 $  J . 6 7 .

5 . 6}   . /     {2 .

          .

&    !"  !& $           J .

 11 $  6 % 12 6 13 . 6 18 . 6 $  J . 6 19 6 20 . 2 15 6 16 . 2 14 .H  6 G6H . G. 5 21 . 5 17 .

 /     {2 .3 $  5             / /        /   . 5 . 6} 2 4.

4 2 $  4 5.     /  G 63 H       /   5 1            5        col ≡ even. n+1 . 8         4             1  "   4   4       .n  4      2 5.5 6 col     /   5  n      /       col .     A  4          /  6  / 4                  4     8/            VVV    4VVV 2 4.6       /    n  $   2n   4      4 4 0  2n − 1   8/   2n − 1       4  F   /         4     4 k   /  k 4 0  2n − 1  8/ n  1                1               0   ?4     n     1.n .   /      col ≡ even. n := ¬col .

          .

2   .8 (a) false (b) false (c) false (d) p (e) false (f) q ≡ r (g) p (h) true 2 5.) &    !"  0  2n − 1   $   4     2n − 1     4  (           /    0             (     1     4     8 /4     4   4     0  2n − 1       4/           /4        1  ?4   4       $   4      /     n−1   $    /                               /         4                    D       1  '       /         1          $      1    /      n−1   2 5.9 ¬true = { 4 ¬p ≡ p ≡ false 4 p := true } true ≡ false = { 4 true ≡ p ≡ p 4 p := false } false .

          .

2 5.11 $    /    /      a ≡ (a ≡ b)   a ≡ (a ≡ b) = { ≡    } (a ≡ a) ≡ b = { G a ≡ a ≡ false H } false ≡ b = { A / ≡ } false ≡ ¬b = { A / J G*!H } b .10 ¬¬p = { 4 ¬p ≡ p ≡ false 4 p := ¬p } ¬p ≡ false = { 4 ¬p ≡ p ≡ false 4 p := p    / 5  } p .&    !"  ) 5.12 6 Q    5 $  Q ≡ A ≡ A ≡ B   Q ≡ ¬B  8 4   4       2 6. 2 5.1 8  5    4        8/                 /       /  /   4          / D       /   /      /  $              /   D         /               $            /   4         4            .

          .

5 .d) = { A / Hn+1.  Tn+1.d = { A / T } length(H0.1 .d) = { A / H0.) &    !"  $    /   4 4   4      $       4       .  4  To.     n+1     /    "                /  /    (  4  "     / F 4 /       /   =4 4 /    /       /  D         F $   (  4 4 /      4 n+1  2 6.d = { A / T } length(Hn+1.d } length.  m  0     D   D  $     5  D   0 G4  5 2×0 H          /    4   m     0      3m  D   3    / 3m−1  D  > /   3   4   F 4       4 4  4  / 5 4    2        4  /       $        /  2×(m−1)    5  A   5  D       $     / 2×(m−1) + 2   2×m     5         8       4     5  D             G            D   D    4                H 8        A 4   2 7.d }   .[ ] = { A / length } 0 .

          .

.¬d) = { A / T G4 H  length } Tn. . 1 .d  0  T1.  D  4  /   5 / H  4     To.2 . 8/ 4 (    5 / n = 0 . ¬d] . $   To.¬d + 1 + Tn.              <<    8             /   <  / 4 4    /    /   << 4      / 4       . 2 .d = 0 Tn+1. Hn. .          (   J    4         /    $    4  A * GB   Æ     A 8  /   9H .¬d + 1 . [n+1 .¬d .¬d .¬d) = { A / length } length(Hn.d  2n−1  $      /    2 7.d G           2 H    Tn.  A     4           1 0        2 0       4     n 0    .d  1  T2.d = 2 × Tn.¬d) + length([n+1 . ¬d]) + length(Hn.d  3 G   /  d H $     / /   5 / Tn+1.&    !"  )! length(Hn. 4 (  4      0  /   G n+1 H0    /    n     4       /   n 0   . (       A     4   /    1    A   2    B   3  4    A   5    B  $   4       /  A   3     /    1     /  3    5       /  B   2     /  ?     /    A                 / $   /  n 0 <<       A   5  / n    $  A      5       /  1           /  2     $     k       5       G   H /  k          /    4        3n F     n 0    ?4 4     4  .

          .

           A  B  C     1 F         4 /   /     $       /  s   t    n 0        /  sp   tp    G n+1 H0    4       p    A  B  C  $  A       /   0  /   G n+1 H0      0  /   n 0          /    $  p       A     p     /  5  /         ?4            n+1            /                F             $   (   /   n+1           0  J        AnB  AnC         BnC  BnA         CnA  CnB  $      4      A +            /         n+1    .          4 J   4      G     n+1 H      4              " A            .)) &    !"  ` . *J 0  / 00       G A +H '    5  / n+1    $  A n     /     /     n     G n+1 H   A     /     $       0  /   n 0      3     0  /   G n+1 H0    $        0  /   G n+1 H0      A   5  / n    /4       A  B  C  .

          .

&    !"  )* AnA ` A  AA ` ` ` `  BnA`  ` `  CnC ` ` ` ` ` ` AA ` ` `   BnC `  A  AA ` ` ` ` ` AA A` AnC `  AnB ` A` CnA A A A ` CnB A  AA ` ` ` ` ` ` ` AA A` BnB . +J "  /   0  /   (n + 1) 0     .

          .

k ≡ d    %  k G     d   / H ! %           d  $     DA  /4 .)+ &    !"  2 7.3 '       /     G4      H 2     /      7.     (  4 4     A k−1           ¬d  /  k  .4 $       (    /4         (  G 4           k   H           k      d   4  k > 1  G     1      H  d  odd.

   /   k      /       $            k−1         ¬d   $       1        d 4  even.1 ≡ d .(k−1) ≡ ¬d  ≡ even.k ≡ d  )  G8 4                             k   / k   I  4                 k H $    /   $4 / =           4   5  /  / 4   k−1  4      k  3   5  /       4           >   4     /            $           (   4              5 2 7.   k  1  "      k  0. 2   .5 $             4      4     6 k      /         I   k  N  4   4  k  0  '      / k   4      k           8/   k            k  1  > 4           d /    %     k−1       ¬d      k    /  .  / 4    d = (odd.

          .

1 (a) $    /        5     / 5 /     /     /    5  F /    /    5  /     /             5 (b) 81        0    /  2×1     C   /   5       5       C    4   0       8/ m     1     5  4  /    5I          5       5 4     0 4 5      (c)  G H /    /  2×1  .   3 × 3         (  4      5   D     5 .2 .               /     5  (m. n)  G8 1  4       <  H $         /     5 (  4  even.&    !"  ) 8. n    1    0    /  2×n           0 0     5      4         4 2 8.6 I n v h c n v h c n v v n h c c h h c n v c h v n $  !J 5 "  / .n  $            /       4     0 0  5     /   4     / 5 $             / 5     /       5 "    /       C  4   3 × 3      C    /    4     5 $            4  A   2 8. >    .m = even.

          .

 J  0    G 4  H /  3 × 3     /   5 .)# &    !"  odd even odd even even .

11 . &  4  / 4    0       %                        .9 $   2 8.  G#H  A                  0/   0   @A  /           $     x  y  z  n    4   $         $    (  /  K   /4L /9 2 8.10  A # $          / F                            ? 4     /        /    8 /               8       /      4   $     /           /  8   4      /     /         /     8      4      4   4    K  L      $     /              /  8 × 6 I     5   K L    0               G               /  6 × 8 H 2 8.

          .

   /     4  A #)  A  G?    H ?4     A     0         5  A  . #J  7 1 "          $                $                    .           (    0    2   .12 .   4          4 $       /    I             8        /   / < 4m × 2n  4  m    2  n    3   Æ       5   A #  #! / (  0      /   < $         /     /  /    0           8 × 6 0     2 8.&    !"  )& .

          .

* &    !"  . &J 3 / 4   /  0      I                        H   .

          .

 J 7 1 "  /  8 × 6   8 × 8  G3     /    I                   A &H   .&    !"  * .

          .

 J 3 / "  "  3    4         $                              .   J 7 1 "  /  6 × 6  $      /  /     .* &    !"  .

          .

Bibliography M !N      -  . -     .

.

   / + .

 W  6 ! M"-# N '4      = "4    7 -      8  88    . #   .   .

 $    / 5     $4 / = .N      % . &#  M.

      .

 '.

.

  JX +  M6#N .

    6 6 $  $4 / = .

     .

 '.

.

 3D    &&  M3D&N ' . 3D  "    .  J )!X )) &# M3D&N ' . 3D '.3 +J $            % && M3&N ' . 3D '.3#!J $              && M3D& N ' .

  .

-     +.

   $(     "      0@ && '.3!*J $   1    M3.N   .

 ( . 31  3  .

   0. +     .

  =  M-#N 3 - 0.

+ .

 .

    $ '  $  0@ &&!    .  M-&!N 3 -  .

   0@ &#   .

          . .

.

(  *!    .

*) M6!N &    !"   6     0.

.

 $ $    $     . ! M #N       0.

1.

2 0 3 '4 "F ? &# .

 0= M&N 8 4 0.

(  (.

 .A  ?  6 && M$*+N / $ ' 4 +.

  4 (.

 .

  4  .

  5678  5689 >(/ . .

 M.#N - . &*+ $  =.  A   /      '.

.

  *J !!X !) &#   .

        .

    .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.