(************** Content-type: application/mathematica ************** CreatedBy='Mathematica 5.1' Mathematica-Compatible Notebook This notebook can be used with any Mathematica-compatible application, such as Mathematica, MathReader or Publicon. The data for the notebook starts with the line containing stars above. To get the notebook into a Mathematica-compatible application, do one of the following: * Save the data starting with the line of stars above into a file with a name ending in .nb, then open the file inside the application; * Copy the data starting with the line of stars above to the clipboard, then use the Paste menu command inside the application. Data for notebooks contains only printable 7-bit ASCII and can be sent directly in email or through ftp in text mode. Newlines can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style). NOTE: If you modify the data for this notebook not in a Mathematica- compatible application, you must delete the line below containing the word CacheID, otherwise Mathematica-compatible applications may try to use invalid cache data. For more information on notebooks and Mathematica-compatible applications, contact Wolfram Research: web: http://www.wolfram.com email: info@wolfram.com phone: +1-217-398-0700 (U.S.) Notebook reader applications are available free of charge from Wolfram Research. *******************************************************************) (*CacheID: 232*) (*NotebookFileLineBreakTest NotebookFileLineBreakTest*) (*NotebookOptionsPosition[ 22098, 506]*) (*NotebookOutlinePosition[ 22830, 532]*) (* CellTagsIndexPosition[ 22786, 528]*) (*WindowFrame->Normal*) Notebook[{ Cell[CellGroupData[{ Cell["Adjacency-free selections of squares from a 2\[Times]N grid", "Section"], Cell["\<\ Here we have a selection of 6 squares from a (2x8) grid, with no \ two squares in the selection (horizontally or vertically) adjacent:\ \>", \ "Text"], Cell[GraphicsData["PostScript", "\<\ %! %%Creator: Mathematica %%AspectRatio: .25 MathPictureStart /Mabs { Mgmatrix idtransform Mtmatrix dtransform } bind def /Mabsadd { Mabs 3 -1 roll add 3 1 roll add exch } bind def %% Graphics %%IncludeResource: font Courier %%IncludeFont: Courier /Courier findfont 10 scalefont setfont % Scaling calculations -0.125 0.125 -0.125 0.125 [ [ 0 0 0 0 ] [ 1 .25 0 0 ] ] MathScale % Start of Graphics 1 setlinecap 1 setlinejoin newpath 0 0 .5 r .25 Mabswid [ ] 0 setdash 0 0 m 0 .25 L s .125 0 m .125 .25 L s .25 0 m .25 .25 L s .375 0 m .375 .25 L s .5 0 m .5 .25 L s .625 0 m .625 .25 L s .75 0 m .75 .25 L s .875 0 m .875 .25 L s 1 0 m 1 .25 L s 0 0 m 1 0 L s 0 .125 m 1 .125 L s 0 .25 m 1 .25 L s 0 0 m 1 0 L 1 .25 L 0 .25 L closepath clip newpath 0 g 0 0 m 0 .125 L .125 .125 L .125 0 L F .125 .125 m .125 .25 L .25 .25 L .25 .125 L F .375 0 m .375 .125 L .5 .125 L .5 0 L F .5 .125 m .5 .25 L .625 .25 L .625 .125 L F .625 0 m .625 .125 L .75 .125 L .75 0 L F .875 0 m .875 .125 L 1 .125 L 1 0 L F % End of Graphics MathPictureEnd \ \>"], "Graphics", ImageSize->{288, 72}, ImageMargins->{{43, 0}, {0, 0}}, ImageRegion->{{0, 1}, {0, 1}}, ImageCache->GraphicsData["Bitmap", "\<\ CF5dJ6E]HGAYHf4PAg9QL6QYHg"], ImageRangeCache->{{{73.4375, 302.812}, {188.625, 132.062}} -> {-1.652, \ 5.66965, 0.0282876, 0.0282876}}], Cell[TextData[{ "It is not hard to derive the following formula for the number ", StyleBox["Af[n,k]", FontWeight->"Bold"], " of adjacency-free selections of ", StyleBox["k", FontSlant->"Italic"], " squares from a (2\[Times]", StyleBox["N", FontSlant->"Italic"], ") grid:" }], "Text"], Cell[BoxData[{ \(\(Af[n_, 0 _] := 1;\)\), "\[IndentingNewLine]", \(Af[n_, k_] := Sum[2^r\ Binomial[k - 1, r - 1] Binomial[n - k + 1, r], {r, 1, k}]\)}], "Input"], Cell["\<\ We can, for instance, make the following table in the style of \ Pascal's Triangle:\ \>", "Text"], Cell[BoxData[{ \(\(AfTriangle = Table[Af[n, k], {n, 0, 12}, {k, 0, n}];\)\), "\[IndentingNewLine]", \(AfTriangle // TableForm\)}], "Input"], Cell[TextData[{ "Many sequences derived from the triangle turn out to have other \ combinatorial interpretations.\nFor instance, columns from the table give \ sequences counting integer lattice points of fixed L1-norm, given by Conway \ and Sloane.\nThe fourth column is Sloane's ", ButtonBox["A035597", ButtonData:>{ URL[ "http://www.research.att.com/~njas/sequences/A035597"], None}, ButtonStyle->"Hyperlink"], StyleBox[":", FontFamily->"Lucida Grande", FontSize->13] }], "Text"], Cell[BoxData[ \(AfTriangle[\([Range[4, 12], 4]\)]\)], "Input"], Cell[TextData[{ "The first interesting diagonal in the table turns out to be Sloane's ", ButtonBox["A005899", ButtonData:>{ URL[ "http://www.research.att.com/~njas/sequences/A005899"], None}, ButtonStyle->"Hyperlink"], ":" }], "Text"], Cell[BoxData[ \(AfTriangle[\([Range[3, 12], \(-3\)]\)]\)], "Input"], Cell[TextData[{ "Totalling the rows gives Sloane's ", ButtonBox["A001333", ButtonData:>{ URL[ "http://www.research.att.com/~njas/sequences/A001333"], None}, ButtonStyle->"Hyperlink"], StyleBox[":", FontFamily->"Lucida Grande", FontSize->13] }], "Text"], Cell[BoxData[ \(Total /@ AfTriangle\)], "Input"], Cell[TextData[{ "The entire triangle, read row-by-row, can be found as Sloane's ", ButtonBox["A035607.", ButtonData:>{ URL[ "http://www.research.att.com/~njas/sequences/A035607"], None}, ButtonStyle->"Hyperlink"] }], "Text"], Cell[TextData[{ "Since we have a computer, we might as well generate pictures (at least, \ that's the moral I've learned from modern calculus textbooks). \nWe will say \ two selections from the 2xN grid have the same class if their projections \ onto the x-axis agree.\nA given projection onto the x-axis has ", Cell[BoxData[ \(TraditionalForm\`2\^r\)]], " lifts to selections on the grid, where r is the number of connected \ components in the projection. For purposes of illustrating the \ possibilities, one selection from each class seems to be sufficient." }], "Text"], Cell[CellGroupData[{ Cell["\<\ Code for enumerating the possible selections and illustrating \ them\ \>", "Subsubsection"], Cell[BoxData[{ \(Projections[n_, k_] := Subsets[Range[n], {k}]\), "\n", \(OneLift[proj_] := Join @@ \((\(MapIndexed[ Flatten[{#1, 1 + Max[0, \((\(-1\))\)^#2]}] &, #] &\) /@ Split[proj, #2 \[LessEqual] #1 + 1 &])\)\), "\n", \(LiftPic[lift_, n_] := Graphics[\(Rectangle[#, # + 1] &\) /@ lift, AspectRatio \[Rule] Automatic, GridLines \[Rule] {Range[n + 1], Range[3]}, PlotRange \[Rule] {{1, n + 1}, {1, 3}}]; \), "\n", \(PrettyPic[n_, k_] := GraphicsArray[ Partition[\(LiftPic[#, n] &\) /@ \(OneLift /@ Projections[n, k]\), 5, 5, {1, 1}, {}], ImageSize \[Rule] 800, GraphicsSpacing \[Rule] {0.2, 0.4}]\), "\n", \(toMatrix[lift_, n_] := ReplacePart[Table[0, {n}, {2}], 1, lift]\)}], "Input"], Cell[BoxData[{ \(AllLifts[proj_List] := Module[{p, t}, \[IndentingNewLine]p = Split[proj, #2 \[LessEqual] #1 + 1 &]; \[IndentingNewLine]t = Tuples[{0, 1}, Length[p]]; \[IndentingNewLine]Join @@@ Table[MapIndexed[{#1, 1 + Max[\((\(-1\))\)^\((#2[\([\)\(2\)\(]\)] + t[\([\)\(i, #2[\([\)\(1\)\(]\)]\)\(]\)])\), 0]} &, p, {2}], {i, Length[t]}]\[IndentingNewLine]]\), "\n", \(\(AllLifts[n_Integer, k_Integer] := Join @@ \(AllLifts /@ Projections[n, k]\);\)\), "\[IndentingNewLine]", \(PrettyBigPic[n_, k_] := GraphicsArray[ Partition[\(LiftPic[#, n] &\) /@ AllLifts[n, k], 5, 5, {1, 1}, {}], ImageSize \[Rule] 800, GraphicsSpacing \[Rule] {0.2, 0.4}]\)}], "Input"] }, Closed]], Cell["\<\ PrettyPic[n,k] will give us a picture of one selection in each \ class (for the problem of choosing k squares from a 2xN grid):\ \>", "Text"], Cell[BoxData[ \(\(Show@PrettyPic[5, 4];\)\)], "Input"], Cell["\<\ PrettyBigPic will give us a picture of all the selections (for the \ problem of choosing k squares from a 2xN grid):\ \>", "Text"], Cell[BoxData[{ \(\(Show@PrettyBigPic[5, 4];\)\), "\[IndentingNewLine]", \(Af[5, 4]\)}], "Input"] }, Open ]], Cell["\<\ The actual sets of squares can be generated by AllLifts. The first \ picture in the second row above, for instance:\ \>", "Text"], Cell[BoxData[{ \(\(selections = AllLifts[5, 4];\)\), "\[IndentingNewLine]", \(Dimensions@selections\), "\[IndentingNewLine]", \(selections[\([6]\)]\)}], "Input"] }, FrontEndVersion->"5.1 for Macintosh", ScreenRectangle->{{0, 1280}, {0, 934}}, CellGrouping->Manual, WindowSize->{910, 906}, WindowMargins->{{4, Automatic}, {Automatic, 1}}, PrintingCopies->1, PrintingPageRange->{1, Automatic}, ShowSelection->True ] (******************************************************************* Cached data follows. If you edit this Notebook file directly, not using Mathematica, you must remove the line containing CacheID at the top of the file. The cache data will then be recreated when you save this file from within Mathematica. *******************************************************************) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[1776, 53, 78, 0, 69, "Section"], Cell[1857, 55, 160, 4, 32, "Text"], Cell[2020, 61, 14596, 277, 80, 1091, 106, "GraphicsData", "PostScript", \ "Graphics"], Cell[16619, 340, 309, 11, 32, "Text"], Cell[16931, 353, 189, 4, 43, "Input"], Cell[17123, 359, 107, 3, 32, "Text"], Cell[17233, 364, 157, 3, 43, "Input"], Cell[17393, 369, 509, 12, 70, "Text"], Cell[17905, 383, 66, 1, 27, "Input"], Cell[17974, 386, 254, 7, 32, "Text"], Cell[18231, 395, 71, 1, 27, "Input"], Cell[18305, 398, 280, 9, 34, "Text"], Cell[18588, 409, 52, 1, 27, "Input"], Cell[18643, 412, 242, 6, 32, "Text"], Cell[18888, 420, 586, 10, 86, "Text"], Cell[CellGroupData[{ Cell[19499, 434, 101, 3, 28, "Subsubsection"], Cell[19603, 439, 824, 17, 155, "Input"], Cell[20430, 458, 853, 17, 139, "Input"] }, Closed]], Cell[21298, 478, 151, 3, 29, "Text"], Cell[21452, 483, 58, 1, 27, "Input"], Cell[21513, 486, 140, 3, 32, "Text"], Cell[21656, 491, 105, 2, 43, "Input"] }, Open ]], Cell[21776, 496, 140, 3, 32, "Text"], Cell[21919, 501, 175, 3, 59, "Input"] } ] *) (******************************************************************* End of Mathematica Notebook file. *******************************************************************)