Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Feel free to use any of this code as you wish, under the MIT license, copyright Azriel Fasten.
{
"metadata": {
"name": "dominosa_demo"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"from dominosa import (dominosa_from_1_in_3_sat, draw_dominosa_to_tikz_strlist,\n",
" tikztemplate_top, tikz_commands, tikztemplate_bottom,\n",
" verify_dominosa_solution, tikz_passed, tikz_failed)\n",
"\n",
"from graphtex import (tex2svg)\n",
"\n",
"from IPython.display import display #, Image\n",
"from IPython.core.display import Image as IImage, SVG\n",
"\n",
"import tempfile\n",
"import subprocess\n",
"\n",
"\n",
"def draw_tikz(tikz_strlist,width=1200,use_png=True):\n",
" \"\"\"\n",
" Draws the insides of a tikzpicture TeX element, which is input as a list of strings.\n",
"\n",
" Draws to ipython notebook.\n",
"\n",
" Optionally draws using a png; this allows saving of the image, or using imgur\n",
" extensions etc. to put it online.\n",
" \"\"\"\n",
" \n",
" tikzpicture = [r'\\begin{tikzpicture}[]','\\n\\n'] + tikz_strlist\n",
" tikzpicture += [r'\\end{tikzpicture}','\\n']\n",
" tikz = [tikztemplate_top, '\\n'*10, tikz_commands] + tikzpicture + ['\\n'*5, tikztemplate_bottom]\n",
" svg = tex2svg(''.join(tikz), scale_to_width=width)\n",
" \n",
" if not use_png:\n",
" display(SVG(data=svg))\n",
" else:\n",
" \n",
" with tempfile.NamedTemporaryFile(suffix='.png') as pngfile:\n",
" with tempfile.NamedTemporaryFile(suffix='.svg') as svgfile:\n",
" svgfile.write(svg)\n",
" svgfile.flush()\n",
" \n",
" cmd = ['rsvg-convert', '-f','png', svgfile.name, '-o', pngfile.name]\n",
" subprocess.check_call(cmd)\n",
" \n",
" display(IImage(filename=pngfile.name))\n",
"\n",
"\n",
"\n",
"def options2dict(**kwargs):\n",
" return dict(kwargs)\n",
"options = options2dict(\n",
" clip_top=True,\n",
" clip_right=True,\n",
" \n",
" draw_all_squares=False,\n",
" draw_wires=False,\n",
" draw_clauses=False,\n",
" draw_forcing_gadgets=False,\n",
" draw_filler_squares=False,\n",
" \n",
" draw_wire_gadgets=False,\n",
" draw_double_clause_gadgets=False,\n",
" draw_clause_gadgets=False,\n",
" draw_contra_clause_gadgets=False,\n",
" mark_forcing_gadgets=False,\n",
" draw_horizontal_walls=False,\n",
" draw_vertical_walls=False,\n",
" \n",
" tile_horizontal_walls=False,\n",
" tile_vertical_walls=False,\n",
" tile_filler_vtiles=False,\n",
" tile_filler_htiles=False,\n",
" tile_witness=False)\n",
"\n",
"\n",
"#cnfx = [(1,3,4),(2,3,4)]\n",
"\n",
"# Vor's example, I think it is UNSAT\n",
"#cnfx = (x1 v -x2 v x3) AND (x2 v -x3 v x4) AND (-x1 v -x3 v x2)\n",
"\n",
"# My example, witness gives 3 different clause states for demonstration\n",
"cnfx = [(1,-2, 3), (2,-3,4), (1,-4,-2)]\n",
"cnf_witness = set([3, 2,-1,-4])\n",
"\n",
"details = dominosa_from_1_in_3_sat(cnfx,witness=cnf_witness,increment_extra_n=True)\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"n = details['n']\n",
"min_width = details['min_width']\n",
"square_placements = details['square_placements']\n",
"witness_htiles = details['witness_htiles']\n",
"witness_vtiles = details['witness_vtiles']\n",
"view_size = 20\n",
"\n",
"verified = verify_dominosa_solution(n,square_placements,witness_htiles,witness_vtiles)\n",
"\n",
"if verified:\n",
" tikz_strlist = tikz_passed()\n",
" draw_tikz(tikz_strlist,width=200)\n",
" \n",
" print 'congrats, witness solution passed verification'\n",
"else:\n",
" tikz_strlist = tikz_failed()\n",
" draw_tikz(tikz_strlist,width=200)\n",
" print 'uh oh, witness solution failed verification'\n",
"\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# just horizontal walls\n",
"options['draw_horizontal_walls']=True\n",
"options['tile_horizontal_walls']=True\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# horizontal walls and gadgets\n",
"options['draw_wires'] = True\n",
"options['draw_clauses'] = True\n",
"options['draw_forcing_gadgets'] = True\n",
"options['draw_wire_gadgets'] = True\n",
"options['draw_clause_gadgets'] = True\n",
"options['draw_contra_clause_gadgets'] = True\n",
"options['mark_forcing_gadgets'] = True\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# draw the vertical walls too\n",
"options['draw_vertical_walls'] = True\n",
"options['tile_vertical_walls'] = True\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# lower left corner, witness\n",
"options['tile_witness'] = True\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)\n",
"\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# lower left corner, witness and filled\n",
"options['draw_filler_squares']=True\n",
"options['tile_filler_htiles']=True\n",
"options['tile_filler_vtiles']=True\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"\n",
"# lower left corner, witness and filled, with spine ends, and with filled-force-gadgets\n",
"options['tile_horizontal_wall_ends']=True\n",
"options['tile_forcing_gadgets']=True\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# lower right corner, witness and filled\n",
"options['clip_top']=False\n",
"options['clip_right']=False\n",
"options['clip_x0'] = n + 2 - view_size\n",
"options['clip_y0'] = None\n",
"options['clip_x1'] = None\n",
"options['clip_y1'] = view_size // 2\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# upper right corner, witness and filled\n",
"options['clip_top']=False\n",
"options['clip_right']=False\n",
"options['clip_x0'] = n + 2 - view_size\n",
"options['clip_y0'] = n + 3 - view_size // 2\n",
"options['clip_x1'] = None\n",
"options['clip_y1'] = None\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)\n"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"\n",
"# upper left corner, witness and filled\n",
"options['clip_top']=False\n",
"options['clip_right']=False\n",
"options['clip_x0'] = None\n",
"options['clip_y0'] = n + 3 - view_size // 2\n",
"options['clip_x1'] = view_size\n",
"options['clip_y1'] = None\n",
"\n",
"tikz_strlist = draw_dominosa_to_tikz_strlist(details,**options)\n",
"draw_tikz(tikz_strlist)\n"
],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}

##${\rm D{\small OMINOSA}}$ is NP-hard


Playing the game is an optimization problem; finding a valid domino tiling such that it covers all the squares. The decision version of this problem is:

Is there a perfect tiling covering a given a $(n+1) \times (n+2)$ grid with $n$ unique tiles?

Obviously, the optimization problem, the problem of actually finding a solution to the game is at least as hard, or harder, than the decision problem.

We will convert a $1\text{-}3\text{-in-}{\rm S{\small AT}}$ formula to a corresponding grid, that will only be coverable iff there is a satisfiable assignment to the formula. Furthermore, the covering can actually be used to recover the satisfying assignment.

Therefore, if the construction presented is correct, and one could solve a game in polynomial time on a DTM, then it would imply ${\rm P=NP}$. This implies ${\rm D {\small OMINOSA}}$ is NP-hard.

###Reduction from $1\text{-}3\text{-in-}{\rm S{\small AT}}$ to ${\rm D {\small OMINOSA}}$

###Introduction

Most of the $3\text{-}{\rm S{\small AT}}$ problems/variants have a pretty good correspondence to ${\rm C{\small IRCUIT}S{\small AT}}$. It can be important to think of the problems in parallel; as they are related to each-other, almost anything in one problem can be related to in the other.

${\rm C{\small IRCUIT}S{\small AT}}$ has a planar variant, to which it reduces, called ${\rm P{\small LANAR}\text{-}C{\small IRCUIT}S{\small AT}}$. This conversion is very elegant, and basically allows you to take any planar embedding, find the remaining crossing wires, and use a "gadget" to let the wires cross via a planar "gate" (collection of gadgets, with input and output wires).

Conveniently, most of the $3\text{-}{\rm S{\small AT}}$ variants also have reductions to planar variants, which parallel ${\rm P{\small LANAR}\text{-}C{\small IRCUIT}S{\small AT}}$, and are very related; easily reducible from one to another, and easy to reason about. So whenever I come to a planar problem that might be NP-hard, I think in terms of the planar variants of $3\text{-}{\rm S{\small AT}}$, and their parallels in ${\rm P{\small LANAR}\text{-}C{\small IRCUIT}S{\small AT}}$.

The planar variants are important to know, because they make help make reductions to planar/geometric problems, like Euclidean TSP (incidentally a pretty rare reduction to find and learn). Thus, there is ${\rm P{\small LANAR}}\text{-}3\text{-}{\rm S{\small AT}}$, and a parellel, ${\rm P{\small LANAR}\text{-}C{\small IRCUIT}S{\small AT}}$, to aid in such reductions.

Other $3\text{-}{\rm S{\small AT}}$ variants are important to know because some of them are weaker; that is, seemingly "easier", yet still NP-complete. They seem easier to solve at first glance - and they are much simpler - yet are still NP-complete. NP-complete, but simpler; and therefore easier to make reductions to, in many cases.

For example, there is $1\text{-in-}3\text{-}{\rm S{\small AT}}$. For some problems, you can easily make an exactly $1\text{-in-}3$ gadget, while making "at least 1 in 3", like the standard $3\text{-}{\rm S{\small AT}}$ uses, would be non-obvious and make for huge constructions.

Another example is ${\rm M{\small ONOTONE}}\text{-}1\text{-in-}3\text{-}{\rm S{\small AT}}$. Monotone makes things a lot simpler when you have a construction that can't easily negate values.

Even more amazing is that ${\rm M{\small ONOTONE}}\text{-}1\text{-in-}3\text{-}{\rm S{\small AT}}$ has a planar variant: ${\rm P{\small LANAR}}\text{-}{\rm M{\small ONOTONE}}\text{-}1\text{-in-}3\text{-}{\rm S{\small AT}}$! So this makes things a lot easier; you don't have to cross "wires" (remember, there are parallels in ${\rm C{\small IRCUIT}S{\small AT}}$ to these), and trust me, while crossing gadgets are fun to make, they tend to be very non-obvious and difficult.

$$ \begin{array}{c|c|c|ccc} &&&&\hspace{1em}&\hline\ {\rm\mathbf{P{\small ROBLEM}}} &\scriptsize{{\rm\mathbf{MONOTONE}}} &\scriptsize{{\rm\mathbf{PLANAR}}} &\scriptsize{{\rm\mathbf{1\text{-in-}3}}} &&{\rm\mathbf{NP\text{-}hard}} \ \hline\ {\rm\mathbf{3\text{-} S{\small AT}}} & \text{No} & \text{No} & \text{No} && \text{Yes}\ \hline\ {\rm\mathbf{M{\small ONOTONE}\text{-}3\text{-} S{\small AT}}} & \text{Yes} & \text{No} & \text{No} && {\text{No}}^1\ {\rm\mathbf{P{\small LANAR}\text{-}3\text{-} S{\small AT}}} & \text{No} & \text{Yes} & \text{No} && {\text{Yes}}^2\ {\rm\mathbf{1\text{-in-}3\text{-} S{\small AT}}} & \text{No} & \text{No} & \text{Yes} && {\text{Yes}}^3\ \hline\ \genfrac{}{}{0}{1} {\rm\mathbf{P{\small LANAR}}} {\rm\mathbf{1\text{-in-}3\text{-} S{\small AT}}} & \text{No} & \text{Yes} & \text{Yes} && {\text{Yes}}^4\\ \genfrac{}{}{0}{1} {{\rm\mathbf{M{\small ONOTONE}\text{-} }}} {{\rm\mathbf{1\text{-in-}3\text{-} S{\small AT}}}} & \text{Yes} & \text{No} & \text{Yes} && {\text{Yes}}^5\\ \genfrac{}{}{0}{1} {{\rm\mathbf{P{\small LANAR}\text{-}}}} {{\rm\mathbf{M{\small ONOTONE}\text{-}3\text{-} S{\small AT}}}} & \text{Yes} & \text{Yes} & \text{No} && {\text{Yes!}}^6\ \hline\ \genfrac{}{}{0}{1} {{\rm\mathbf{P{\small LANAR}\text{-}M{\small ONOTONE}\text{-} }}} {{\rm\mathbf{1\text{-in-}3\text{-}S{\small AT}}}} & \text{Yes} & \text{Yes} & \text{Yes} && {\text{Yes}}^7\ \end{array} $$

  1. Pure literal elimination
  2. Schaefer's dichotomy theorem
  3. The Problem of Compatible Representatives
  4. Minimum Weight Triangulation is NP-Hard
  5. Schaefer's dichotomy theorem
  6. Finding Perfect Auto-Partitions is NP-hard
  7. Optimal Binary Space Partitions in the Plane

One way to start with a reduction, is to try to find "gadgets" that resemble wires, and a gadget that resembles a clause of one of the $3\text{-}{\rm S{\small AT}}$ variants. As a bonus, many of the variants are planar, we can probably get away without crossing wires.

What is a "gadget"? A gadget is some construction in the problem, that is helpful as a building block to build gates/wires/clauses. Some gadgets will have a restricted set of states; for example, a gadget with two states can be used as a variable; one state is "true" and the other is "false". A gadget with two states, that can be "long", can bend, and split, is useful as a wire - if it can interact with a variable, and become constrained to extend the state of the variable to another location. A gadget with exactly three states can perhaps be used as a clause; if it can be used to constrain "one of three" wires via each one of its three states. Similarly, one might want all sorts of logic gates, like a not-gadget, an or-gadget, an xor-gadget etc; where you can have some sort of constraint via the gadget that relates 2 or 3 wires in such a way.

###A Building-block

  • First, let's reserve a number, for example, $\mathbf 1$, on the board. We will make $\mathbf 1$ a building block for everything else.
  • We will use a corner to make sure that $\mathbf 1$ can never connect to another $\mathbf 1$, except in this corner, where it must.
  • Below (in the three figures) is the corner, and how we place the $\mathbf 1$s there.
  • We will use the $\star$ to indicate unique values in all the grid, in all the diagrams.
  • In fact, we will cover our grid with $\star$ values before overlaying them with important values; therefore, by default cover everything with $\star$ values.

enter image description here

As you can see, by placing the $3$   $\mathbf{1}$s the pair $\mathbf{(1,1)}$ must be used up in this configuration; it must use one of the dashed-tiles. Now $\mathbf{(1,1)}$ can never happen elsewhere in the board, which is what we need.

There are alternate ways of reserving a number, either against the wall with $4$ of them, or in the middle of nowhere, with $5$ of them in a cross. Any way is fine, as long as $\mathbf{(1,1)}$ is forced.

###A Wall

Now, it would be very useful to be able to make "walls" and "corners" all over the place, not just at the sides of the grid. Look what happens if we line up pairs of ones in a line; the one's have no choice but to pair with their neighbors, making a "wall" of width $4$.

Images below, from left to right:

  1. A line of pairs of $\mathbf 1$s.
  2. The only possible tiling of that $\mathbf 1$-square.
  3. The only possible tiling of (almost) all the $\mathbf 1$s in the line.
  4. The wall line, drawn for emphasis.

enter image description here

###An initial attempt at a wire

Now, by placing two "walls" opposite each-other, and leaving a space of $\mathbf 1$ between the walls, perhaps we can come up with a "wire"-like gadget.

Showing only the wall-borders, this is what we get in the figures below (left to right):

  • Placing two walls opposite each-other.
  • Putting unique numbers inside.
  • Rightmost two: Two possible states of the wire.

enter image description here

How it works:

There cannot be any holes in the tube/wire, therefore, if the the tiles are shifted up, then they all must be shifted up, all along the tube; if they are shifted down, it will "suck" down all of them. Thus, we can send a "signal" from one side of the wire to the other; in other words, propagate a value.

Thus, now we can propagate a value across long distances!

Remaining limitations are:

  • We cannot bend a wire,
  • We cannot split a wire,
  • We cannot cross wires,
  • We might have annoying layout issues because we must be careful about wire-length parity.

###Bending a Wire, Part 1: Wall Below

Next problem is, we need to be able to bend a wire, not just go straight ...

So. We will break the bending part down into two parts; the upper part and the lower part. First the lower part. Ignore the upper part of the bend, we will do that later.

The figures below show a bit of a problem with bending; the top of the wire is "loose", it seems difficult to make a wall that turns a sharp 90 degrees.

Left to right:

  • The top of a wire is "loose".
  • What happens if we try to bend it; we want to wire to be in between the blue lines. Again, Ignore the upper part of the bend, we will do that later.
  • As you can see, the top $\mathbf 1$s are loose, they can tile along the wall, or through the wire! This is no good.

enter image description here

One solution is as follows:

  • Pick a $\mathbf{(x,1)}$ pair near the bend. Take the value of that $\mathbf x$ square, let us name it $\mathbf{ q \star}$; this means the number is unique in the entire grid, just like $\mathbf \star$, and is reused once, here in this bend only. Because this $\mathbf x$ is paired with a $\mathbf 1$, it cannot be paired with a $\mathbf 1$ again. Therefore, we place it right on top of the rightmost-topmost $\mathbf 1$. Now, we can clearly see, the only option remaining to pair for that $\mathbf 1$ is to its right, and thus it will solidify the wall.

Illustration below, description from left to right:

  • The situation with the problem.
  • Pick a square, let $\mathbf{q \star}$ be the square value of any square in the bend (of course not $\mathbf 1$s though).
  • The two togglings of the rightmost-topmost $\mathbf 1$ tilings; this time, only one of them is valid.

enter image description here

However, how can we be sure this $\mathbf {{q}{\star}}$ won't ruin the wire? Below you can see the states of the wire, and that the $\mathbf {{q}{\star}}$ will not hamper with it.

From left to right:

  • The current construction.
  • Two rightmost figures: The states of the wire; empirically, they are not hampered by the introduction of $\mathbf {{q}{\star}}$.

enter image description here

Now we still have a loose $\mathbf 1$ on top; the leftmost-topmost-$\mathbf 1$.

We will do the same thing; pick a pair $\mathbf{({r}{\star},1)}$ that is already paired in the bend-tiles, and place $\mathbf{r}{\star}$ on top of the leftmost-topmost-$\mathbf 1$.

Illustration below, left to right:

  • Our current construction.
  • The problem: leftmost-topmost-$\mathbf 1$ can pair with a number in the wire, or with the wall; we want it to only pair with the wall.
  • Choosing an $\mathbf{r}{\star}$, and using the same number on top of the leftmost-topmost-$\mathbf 1$.

enter image description here

And we finally get our lower bend. Illustration below, descriptions, from left to right:

  • Left: Our final construction for a bend.
  • Right: How to continue the wire to the left.

enter image description here

###Bending a Wire, Part 2: Wall Above

The walls to make the top corner of the bend are much simpler. You simple align a vertical wall with a horizontal wall. Illustration below, description from left to right:

  • The wire-bend we want to make.
  • Place the vertical section of the wall squares down.
  • Tiling the squares of the vertical-wall.
  • Placement and tiling of the horizontal wall; it can meet the vertical wall, and form a corner.

enter image description here

Now you should be convinced that we can place and bend wires. We still can't split or cross wires though, more on that later.

Remaining limitations are:

  • We cannot bend a wire,
  • We cannot split a wire,
  • We cannot cross wires,
  • We might have annoying layout issues because we must be careful about wire-length parity.

###A Valued Wire

Now we have wires, it would be nice to have a valued-wire, where we can see the value of a wire, like an LED on a circuit board. So what we do, is take a wire, say of length $7$, and introduced a named $\star$ square, we'll call it ${\mathcal T}{\star}$, and another named square, we'll call it ${\mathcal F}{\star}$. These are both unique to each valued wire section, ie. only twice, and they will only get reused within a single valued wire. They are placed in pairs, the two ${\mathcal T}{\star}$ squares right next to each-other, and the two ${\mathcal F}{\star}$ squares next to each-other, with a single $\star$ square separating them. Illustrated below, description from left to right:

  • Left: A wire.
  • Right: The square-configuration.

enter image description here

So how do we tell if a wire is true or false? Well, a wire has two states. In each of these states, one of ${\mathcal T}{\star}$ or ${\mathcal F}{\star}$ will be paired in the same tile; the value that is paired is the value of the wire. Illustration below, desciption from left to right:

  • Left, right: The two states of the valued wire;
  • Left: Wire is valued trued, as the ${\mathcal T}{\star}$ squares share a single tile
  • Right: Wire is valued false as the ${\mathcal F}{\star}$ squares share a single tile.

enter image description here

We can now have named variable that we can use, to place our ${\rm 3\text{-}S{\small AT}}$ variables down on the grid. We can connect two valued wires and force them to have the same value, or if we connect them with an odd-length, force them to have different values; and using wires, we can do this long-distance, across the grid. Using wires, we can propagate the values of the named variables all over the place.

Remaining limitations are:

  • We cannot split a wire,
  • We cannot cross wires,
  • We might have annoying layout issues because we must be careful about wire-length parity.

###Not-gate

A not-gate is unnecessary as it is implicit: simply using an off-by-one wire length we can negate the value of the wire.

###A Clause Gate

Now I can demonstrate a simple clause gadget; it will connect to $3$ wires, and force one of them to be "pulled" state, and force the other two to be in the "pushed" state. We can use this, this is an exactly one-in-three relationship; we set the odd-wire-state to mean "true", and the other two wire-states to mean "false", and we are set.

Illustrations below, descriptions from left to right:

  • The wire-layout of the clause gadget. It makes a "plus" sign; the joining of 3 wires in one spot.
  • Fill the wire with unique $\star$ squares.
  • The three states of the center square. Each of these states "pulls" exactly one wire into the center, the essential point of the gate; to act like a ${\rm 1\text{-in-}3\text{-}S{\small AT}}$ clause.

enter image description here

Now let's take a look at the different states. Illustration below, description from left to right:

  • The left wire is pulled into the center; the other two are pushed out.
  • The bottom wire is pulled into the center; the other two are pushed out.
  • The bottom-right wire is pulled into the center; the other two are pushed out.

enter image description here

Now, if you attach wires with the right length-parity (even or odd length) to the end of this gate, only one of them could be true, the other two false (depending if you attach them oddly, you can generalize this a bit). Thus we can connect $3$ values into a $1\text{-in-}3$ CNF clause.

Remaining limitations are:

  • We cannot split a wire,
  • We cannot cross wires,
  • We might have annoying layout issues because we must be careful about wire-length parity.

###Splitting a Wire

To split a wire, we first line up two wires next to each-other. Next, as a visual aid, we label each of the wires with two ${\mathcal T}{\star}$ squares, one next to the other. This will allow us to see when the wire is "true": when the two ${\mathcal T}{\star}$ squares of a wire in a single tile, then it will be true, otherwise false. Each wire should get its own pair of ${\mathcal T}{\star}$ pairs, so we'll name one pair ${\mathcal T}_1{\star}$ and the other ${\mathcal T_2}{\star}$. Then we introduce three new named-unique $\star$ values, $a{\star},b{\star},c{\star}$. We will place these three next to each-other, once on each wire. However, on one wire, keep a single $\star$ squares between the $a{\star},b{\star},c{\star}$ squares and the ${\mathcal T}{\star}$ pair. On the other wire, put two $\star$ squares between the $a{\star},b{\star},c{\star}$ squares.

Illustration below, description from left to right:

  • Wire layout. Note the walls are a bit thick, so the wires are drawn closer together for illustration purposes; in reality, they are a bit farther apart.
  • The square-values; the ${\mathcal T}{\star}$ values on top, and the split-connectors $a{\star},b{\star},c{\star}$ beneath.

enter image description here

What this does is force the wires not to be different; if $a{\star},b{\star}$ is tiled on one wire, then the second wire cannot be off-by-one, because then that would imply $a{\star},b{\star}$ is tiled on the second wire, and thus $a{\star},b{\star}$ would be tiled twice. Illustration below, description from left to right:

  • Example state of the left wire, valued as true.
  • Bad state of the second wire; it tries to be differently valued, but then it gets a duplicate pair.
  • Good state of the second wire, now they are the same value, and there are no duplicate pairs.

enter image description here

If you play around with the other two possible states, you will see this extends to those as well, and it works both ways. Thus these two wires are now the same; we have successfully split a wire. We can split the wire as many times as we like, each time using a new set of $a{\star},b{\star},c{\star}$.

Remaining limitations are:

  • We cannot split a wire,
  • We cannot cross wires,
  • We might have annoying layout issues because we must be careful about wire-length parity.

###A Cordless Wire!

Well, to my delight, splitting a wire turned out to be cordless! That is, in the illustrations above, I lay the wires next to each-other, but there is no reason to! We can place the wires anywhere on the grid, and they'd still be "entangled" so-to-speak. This saves us a lot of trouble:

  • We don't even have to worry about crossing wires. This lets us reduce from non-planar variants of ${\rm\mathbf{3\text{-} S{\small AT}}}$
  • We have to do any annoying layout, getting the wires to their locations, it is easy! Like a cordless phone! Freedom!
  • We don't have to worry about wire-length parity/off-by-one layout.
  • We can make pretty minimally sized reduction; the variables will each get a single set of long wire strips, with a lot of cordless connections along the wires. These connections will be to clause-gates, which will reside in its own location on the grid. The clause will now only consist of the clause gadget and three cordless wires sticking out of it.

Remaining limitations are:

  • We cannot cross wires,
  • We might have annoying layout issues because we must be careful about wire-length parity.

###The Reduction, first attempt

Let $\Phi(\mathbf x)= \bigwedge_i C_i$ be a $1\text{-in-}3\text{-}{\rm S{\small AT}}$ boolean formula.

  • For each $x_j \in \mathbf x$, lay-out a single long wire, in rows, near the bottom of the grid.
  • For each $C_i \in \Phi(\mathbf x)$, make a clause-gate at the top of the grid; you can lay them out however you like; best fill it up in a square area, but you can lay it out in a single long row as well.
  • For each $x_j$ variable participating in a clause $C_i$, place a cordless-wire at one of the $3$ wire-pins of the clause gate; place the other $a{\star},b{\star},c{\star}$ of each connection onto the corresponding variable wire/row. Negated terms should just place the cordless connection to the clause a distance of one farther away, changing the wire-length-parity, and negating the value.

What it might look like:

  • Figure: A clause, directly connected to cordless wires. "Hotspots" are the way we symbolize the $a{\star},b{\star},c{\star}$ from here on. These hotpots will each be connected to the variables in the grid.

enter image description here

And here is what the grid might look like:

  • Figure: The resulting game-board. The variables are lined up in rows on the bottom. The clauses are spread out across the top. This layout gives quadratic blowup; a smarter layout can avoid quadratic blowup.

enter image description here

###Last Minute Details

Recall the decision problem:

Is there a perfect tiling covering a given a $(n+1) \times (n+2)$ grid with $n$ unique tiles?

So for an $(n+1) \times (n+2)$ grid, we can only use $n$ variables. But our reduction requires a lot of unique variables, much more than $\mathcal O(n)$. There are several ways to solve this issue.

  • One way, is to square the size of the grid in both axes. So now our $\mathcal O\left(|\mathbf x|\times \left|\Phi(\mathbf x)\right|\right)$ grid is merely $\in \mathcal O\left(n\right)$, which means all of our unique numbers can be bounded by $n$. Then, we must fill up the rest of the grid, reusing our unique numbers, but being very careful not to place any numbers that our adjacent to each-other in our grid, adjacent to each-other in the filler-space of the rest of the grid. There are several creative ways to do this, I'll leave that as an exercise. This method induces an additional quadratic blowup, obviously.
  • Another, more succinct, more complex way, is to diversify the $\mathbf 1$ block. Instead of just one building block, we can use $\mathcal O(n)$ building blocks, and then we can reuse the numbers they pair with. This method allows us to avoid quadtratic blowup.

###Graph sources

\documentclass[tikz,margin=5em]{standalone}
\usepackage{intcalc,calc}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{amsmath}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{shapes}
\usetikzlibrary{fadings}
\title{Dominosa.Part.I}
\begin{document}
\def\tilecolor{gray}
\def\squarecolor{gray!40!white}
\tikzset{dstyle/.style={line width=0.5 mm,rounded corners,fill=gray,fill opacity=.3}}
\tikzset{snode/.style={rounded corners,fill=\squarecolor,
text opacity=1,fill opacity=1,
minimum size=1 cm,font=\bfseries}}
\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\tikzset{bline/.style={rounded corners,line width=.5mm,color=black}}
\tikzset{darrow/.style={-stealth,line width=.5mm}}
\tikzset{idarrow/.style={stealth-,line width=.5mm}}
\tikzset{gstyle/.style={step=1cm,black,line width=.1mm,opacity=.3}}
\def\tilemargin{.05}
\def\kleene{${\star}$}
\def\numeralA{$\mathbf{1}$}
\def\qkleene{${\mathbf q}{\star}$}
\def\rkleene{${\mathbf r}{\star}$}
\def\cornerLength{5}
\def\tkleene{${\mathcal T}{\star}$}
\def\fkleene{${\mathcal F}{\star}$}
\newcommand*{\vtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\dvtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\htile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\dhtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\square}[3]{
\def\x{#1}
\def\y{#2}
\def\sname{#3}
\node[snode] at (\x+.5,\y+.5) {\sname};
}
\newcommand*{\vspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\square{\xb+0}{\yb+\j}{\kleene};
\square{\xb+1}{\yb+\j}{\numeralA};
\square{\xb+2}{\yb+\j}{\numeralA};
\square{\xb+3}{\yb+\j}{\kleene};
}
}
\newcommand*{\vspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\htile{\xb+0}{\yb+\j};
\htile{\xb+2}{\yb+\j};
}
}
\newcommand*{\hspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\square{\xb+\j}{\yb+0}{\kleene};
\square{\xb+\j}{\yb+1}{\numeralA};
\square{\xb+\j}{\yb+2}{\numeralA};
\square{\xb+\j}{\yb+3}{\kleene};
}
}
\newcommand*{\hspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\vtile{\xb+\j}{\yb+0};
\vtile{\xb+\j}{\yb+2};
}
}
\newcommand{\AslideA}{
\draw[bline] (0,\cornerLength) -- (0,0) -- (\cornerLength,0);
}
\newcommand{\AslideB}{
\AslideA;
\square{0}{0}{\numeralA};
\square{0}{1}{\numeralA};
\square{1}{0}{\numeralA};
\square{1}{1}{\kleene};
\square{0}{2}{\kleene};
\square{1}{2}{\kleene};
\square{2}{2}{\kleene};
\square{2}{1}{\kleene};
\square{2}{0}{\kleene};
\draw[bline] (0,\cornerLength) -- (0,0) -- (\cornerLength,0);
}
\newcommand{\AslideC}{
\AslideB;
\dvtile{0}{0};\dhtile{0}{0};
\draw[bline] (0,\cornerLength) -- (0,0) -- (\cornerLength,0);
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,6);
%--------------------------------
\AslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,6);
%--------------------------------
\AslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,6);
%--------------------------------
\AslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (6,6);
\AslideA;
\end{scope}
\begin{scope}[shift={(9,0)}]
\draw[gstyle] (-1,-1) grid (6,6);
\AslideB;
\end{scope}
\begin{scope}[shift={(18,0)}]
\draw[gstyle] (-1,-1) grid (6,6);
\AslideC;
\end{scope}
\end{tikzpicture}
\newcommand{\BslideA}{
\vspine{0}{0}{8};
}
\newcommand{\BslideB}{
\BslideA;
\htile{0}{1};
}
\newcommand{\BslideC}{
\BslideA;
\vspinecover{0}{0}{8};
}
\newcommand{\BslideD}{
\BslideC;
\draw[wline] (4,1) -- (4,7);
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (5,9);
%--------------------------------
\BslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (5,9);
%--------------------------------
\BslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (5,9);
%--------------------------------
\BslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (5,9);
%--------------------------------
\BslideD;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (5,9);
\BslideA;
\end{scope}
\begin{scope}[shift={(8,0)}]
\draw[gstyle] (-1,-1) grid (5,9);
\BslideB;
\end{scope}
\begin{scope}[shift={(16,0)}]
\draw[gstyle] (-1,-1) grid (5,9);
\BslideC;
\end{scope}
\begin{scope}[shift={(24,0)}]
\draw[gstyle] (-1,-1) grid (5,9);
\BslideD;
\end{scope}
\end{tikzpicture}
\newcommand{\BBslideA}{
\def\wireheight{5};
\begin{scope}
\path [scope fading=west] (0,0) rectangle (2,\wireheight);
\fill [fill=\squarecolor] (0,0) rectangle (2,\wireheight);
\end{scope}
\begin{scope}
\path [scope fading=east] (3,0) rectangle (5,\wireheight);
\fill [fill=\squarecolor] (3,0) rectangle (5,\wireheight);
\end{scope}
\draw[wline] (2,0) -- (2,\wireheight);
\draw[wline] (3,0) -- (3,\wireheight);
}
\newcommand{\BBslideB}{
\square{2}{0}{\kleene};
\square{2}{1}{\kleene};
\square{2}{2}{\kleene};
\square{2}{3}{\kleene};
\square{2}{4}{\kleene};
\begin{scope}
\clip (0,5) rectangle (5,6);
\path [scope fading=north] (0,5) rectangle (5,6);
\square{2}{5}{\kleene};
\end{scope}
\begin{scope}
\clip (0,-1) rectangle (5,0);
\path [scope fading=south] (0,-1) rectangle (5,0);
\square{2}{-1}{\kleene};
\end{scope}
\BBslideA;
}
\newcommand{\BBslideC}{
\BBslideB;
\begin{scope}
\clip (0,5) rectangle (5,6);
\path [scope fading=north] (0,5) rectangle (5,6);
\end{scope}
\begin{scope}
\clip (0,-1) rectangle (5,0);
\path [scope fading=south] (0,-1) rectangle (5,0);
\dvtile{2}{-2};
\end{scope}
\dvtile{2}{0};
\dvtile{2}{2};
\dvtile{2}{4};
\draw[darrow] (4.5,0.5) -- (4.5,4.5);
}
\newcommand{\BBslideD}{
\BBslideB;
\begin{scope}
\clip (0,5) rectangle (5,6);
\path [scope fading=north] (0,5) rectangle (5,6);
\dvtile{2}{5};
\end{scope}
\begin{scope}
\clip (0,-1) rectangle (5,0);
\path [scope fading=south] (0,-1) rectangle (5,0);
\end{scope}
\dvtile{2}{-1};
\dvtile{2}{1};
\dvtile{2}{3};
\draw[idarrow] (4.5,0.5) -- (4.5,4.5);
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-2) grid (6,7);
%--------------------------------
\BBslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-2) grid (6,7);
%--------------------------------
\BBslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-2) grid (6,7);
%--------------------------------
\BBslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-2) grid (6,7);
%--------------------------------
\BBslideD;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (0,-2) grid (5,7);
\BBslideA;
\end{scope}
\begin{scope}[shift={(7,0)}]
\draw[gstyle] (0,-2) grid (5,7);
\BBslideB;
\end{scope}
\begin{scope}[shift={(14,0)}]
\draw[gstyle] (0,-2) grid (5,7);
\BBslideC;
\end{scope}
\begin{scope}[shift={(21,0)}]
\draw[gstyle] (0,-2) grid (5,7);
\BBslideD;
\end{scope}
\end{tikzpicture}
\newcommand{\CslideA}{
\vspine{0}{0}{3};
\vspinecover{0}{-1}{4};
\begin{scope}
\path [scope fading=south] (0,0) rectangle (6,-1);
\vspine{0}{-1}{1};
\vspinecover{0}{-2}{3};
\draw[wline] (4,-2) -- (4,0);
\draw[wline] (5,-2) -- (5,0);
\end{scope}
\draw[wline] (4,0) -- (4,2);
\draw[wline] (5,0) -- (5,2);
\node at (2,-1.3) {...};
\node at (2,-2.3) {...};
\draw[darrow] (2,-1.5) -- (2,-2.0);
}
\newcommand{\CslideB}{
\CslideA;
\square{0}{3}{\kleene};
\square{1}{3}{\kleene};
\square{2}{3}{\kleene};
\square{3}{3}{\kleene};
\square{4}{3}{\kleene};
\square{4}{2}{\kleene};
\square{4}{1}{\kleene};
\square{4}{0}{\kleene};
\begin{scope}
\path [scope fading=south] (0,0) rectangle (6,-1);
\square{4}{-1}{\kleene};
\draw[wline] (4,-2) -- (4,0);
\draw[wline] (5,-2) -- (5,0);
\end{scope}
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideC}{
\CslideB;
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideD}{
\CslideC;
\dhtile{2}{2};
\dvtile{2}{2};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideE}{
\CslideC;
\square{3}{3}{\kleene};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideF}{
\CslideB;
\square{2}{3}{\qkleene};
\square{0}{0}{\qkleene};
\square{1}{0}{\numeralA};
\htile{0}{0};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideG}{
\CslideF;
\dvtile{2}{2};
\dhtile{2}{2};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideH}{
\CslideF;
\htile{2}{2};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideI}{
\CslideH;
\begin{scope}
\path [scope fading=south] (0,0) rectangle (6,-1);
\dvtile{4}{-2};
\end{scope}
\dhtile{0}{3};
\dhtile{2}{3};
\dvtile{4}{2};
\dvtile{4}{0};
\draw[idarrow] (.5,4.5) -- (4.5,4.5);
\draw[darrow] (5.5,.5) -- (5.5,3.5);
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideJ}{
\CslideH;
\begin{scope}
\clip (0,0) rectangle (6,5);
\dvtile{4}{-1};
\end{scope}
\begin{scope}
\clip (0,0) rectangle (6,-1);
\path [scope fading=south] (0,0) rectangle (6,-1);
\dvtile{4}{-1};
\end{scope}
\dhtile{-1}{3};
\dhtile{1}{3};
\dhtile{3}{3};
\dvtile{4}{1};
\draw[darrow] (.5,4.5) -- (4.5,4.5);
\draw[idarrow] (5.5,.5) -- (5.5,3.5);
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideK}{
\CslideH;
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideL}{
\CslideH;
\dhtile{0}{2};
\dvtile{1}{2};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideM}{
\CslideH;
\square{1}{3}{\rkleene};
\square{0}{1}{\rkleene};
\square{1}{1}{\numeralA};
\htile{0}{1}
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideO}{
\CslideM;
\htile{0}{2};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
}
\newcommand{\CslideP}{
\square{-2}{3}{\kleene};
\square{-1}{3}{\kleene};
\CslideO;
\hspine{-2}{-1}{2};
\hspinecover{-3}{-1}{4};
\begin{scope}
\clip (-3,-1) rectangle (-2,5);
\path [scope fading=west] (-3,-1) rectangle (-2,5);
\square{-3}{3}{\kleene};
\hspine{-3}{-1}{1};
\hspinecover{-4}{-1}{3};
\draw[wline] (4,3) -- (-3,3);
\draw[wline] (5,4) -- (-3,4);
\end{scope}
\node at(-4.3,1) {...};
\node at(-3.3,1) {...};
\draw[darrow] (-3.5,1) -- (-4,1);
\draw[wline] (4,0) -- (4,3) -- (-2,3);
\draw[wline] (5,0) -- (5,4) -- (-2,4);
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideD;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideE;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideF;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideG;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideH;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideI;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideJ;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideK;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideL;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideM;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (6,5);
%--------------------------------
\CslideO;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-4,-2) grid (6,5);
%--------------------------------
\CslideP;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideA;
\end{scope}
\begin{scope}[shift={(9,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideB;
\end{scope}
\begin{scope}[shift={(18,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideD;
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideE;
\end{scope}
\begin{scope}[shift={(9,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideF;
\end{scope}
\begin{scope}[shift={(18,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideG;
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideH;
\end{scope}
\begin{scope}[shift={(9,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideI;
\end{scope}
\begin{scope}[shift={(18,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideJ;
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideK;
\end{scope}
\begin{scope}[shift={(9,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideL;
\end{scope}
\begin{scope}[shift={(18,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideM;
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (6,5);
\CslideO;
\end{scope}
\begin{scope}[shift={(13,0)}]
\draw[gstyle] (-3,-1) grid (6,5);
\CslideP;
\end{scope}
\end{tikzpicture}
\newcommand{\DslideA}{
\begin{scope}[]
\square{4}{0}{\kleene};
\square{4}{1}{\kleene};
\square{4}{2}{\kleene};
\square{4}{3}{\kleene};
\square{3}{3}{\kleene};
\square{2}{3}{\kleene};
\square{1}{3}{\kleene};
\square{0}{3}{\kleene};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
\end{scope}
}
\newcommand{\DslideB}{
\DslideA;
\node at (7,-0.3) {...};
\node at (7,-1.3) {...};
\draw[darrow] (7,-0.5) -- (7,-1.0);
\begin{scope}[]
\vspine{5}{0}{8};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
\end{scope}
}
\newcommand{\DslideC}{
\DslideB;
\begin{scope}[]
\vspine{5}{0}{8};
\vspinecover{5}{-1}{9};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
\end{scope}
}
\newcommand{\DslideD}{
\node at (-1.3,6) {...};
\node at (-0.2,6) {...};
\draw[darrow] (-0.5,6) -- (-1,6);
\DslideC;
\begin{scope}[]
\hspine{0}{4}{5};
\hspinecover{-1}{4}{7};
\draw[wline] (4,0) -- (4,3) -- (0,3);
\draw[wline] (5,0) -- (5,4) -- (0,4);
\end{scope}
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\DslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\DslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\DslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\DslideD;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(-8,0)}]
\draw[gstyle] (-1,-1) grid (6,9);
\DslideA;
\end{scope}
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\DslideB;
\end{scope}
\begin{scope}[shift={(12,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\DslideC;
\end{scope}
\begin{scope}[shift={(24,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\DslideD;
\end{scope}
\end{tikzpicture}
\end{document}
\documentclass[tikz,margin=5em]{standalone}
\usepackage{intcalc,calc}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{amsmath,amssymb}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{relsize}
\usetikzlibrary{shapes}
\usetikzlibrary{fadings}
\title{Dominosa.Part.II}
\begin{document}
\def\tilecolor{gray}
\def\squarecolor{gray!40!white}
\tikzset{dstyle/.style={line width=0.5 mm,rounded corners,fill=gray,fill opacity=.3}}
\tikzset{snode/.style={rounded corners,fill=\squarecolor,
text opacity=1,fill opacity=1,
minimum size=1 cm,font=\bfseries}}
\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\tikzset{bline/.style={rounded corners,line width=.5mm,color=black}}
\tikzset{darrow/.style={-stealth,line width=.5mm}}
\tikzset{idarrow/.style={stealth-,line width=.5mm}}
\tikzset{gstyle/.style={step=1cm,black,line width=.1mm,opacity=.3}}
\tikzset{checknode/.style = {font=\relsize{#1}}}
\def\tilemargin{.05}
\def\kleene{${\star}$}
\def\numeralA{$\mathbf{1}$}
\def\qkleene{${\mathbf q}{\star}$}
\def\rkleene{${\mathbf r}{\star}$}
\def\cornerLength{5}
\def\tkleene{${\mathcal T}{\star}$}
\def\fkleene{${\mathcal F}{\star}$}
\newcommand*{\vtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\dvtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\htile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\dhtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\Dsquare}[3]{
\def\x{#1}
\def\y{#2}
\def\sname{#3}
\node[snode] at (\x+.5,\y+.5) {\sname};
}
\newcommand*{\vspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\Dsquare{\xb+0}{\yb+\j}{\kleene};
\Dsquare{\xb+1}{\yb+\j}{\numeralA};
\Dsquare{\xb+2}{\yb+\j}{\numeralA};
\Dsquare{\xb+3}{\yb+\j}{\kleene};
}
}
\newcommand*{\vspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\htile{\xb+0}{\yb+\j};
\htile{\xb+2}{\yb+\j};
}
}
\newcommand*{\hspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\Dsquare{\xb+\j}{\yb+0}{\kleene};
\Dsquare{\xb+\j}{\yb+1}{\numeralA};
\Dsquare{\xb+\j}{\yb+2}{\numeralA};
\Dsquare{\xb+\j}{\yb+3}{\kleene};
}
}
\newcommand*{\hspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\vtile{\xb+\j}{\yb+0};
\vtile{\xb+\j}{\yb+2};
}
}
\newcommand{\FslideA}
{
\begin{scope}
\fill [fill=\squarecolor, path fading=west] (0,0) rectangle (3,7);
\fill [fill=\squarecolor,path fading=east] (4,0) rectangle (7,7);
\draw[wline] (3,0) -- (3,7);
\draw[wline] (4,0) -- (4,7);
\end{scope}
}
\newcommand{\FslideB}
{
\FslideA;
\begin{scope}
\Dsquare{3}{0}{\kleene};
\Dsquare{3}{1}{\tkleene};
\Dsquare{3}{2}{\tkleene};
\Dsquare{3}{3}{\kleene};
\Dsquare{3}{4}{\fkleene};
\Dsquare{3}{5}{\fkleene};
\Dsquare{3}{6}{\kleene};
\draw[wline] (3,0) -- (3,7);
\draw[wline] (4,0) -- (4,7);
\end{scope}
}
\newcommand{\FslideC}
{
\FslideB;
\begin{scope}
\vtile{3}{-1};
\vtile{3}{1};
\vtile{3}{3};
\vtile{3}{5};
\draw[wline] (3,0) -- (3,7);
\draw[wline] (4,0) -- (4,7);
\end{scope}
}
\newcommand{\FslideD}
{
\FslideB;
\begin{scope}
\vtile{3}{0};
\vtile{3}{2};
\vtile{3}{4};
\vtile{3}{6};
\draw[wline] (3,0) -- (3,7);
\draw[wline] (4,0) -- (4,7);
\end{scope}
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (8,8);
%--------------------------------
\FslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (8,8);
%--------------------------------
\FslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (8,8);
%--------------------------------
\FslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (8,8);
%--------------------------------
\FslideD;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (8,8);
\FslideA;
\end{scope}
\begin{scope}[shift={(11,0)}]
\draw[gstyle] (-1,-1) grid (8,8);
\FslideB;
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (8,8);
\FslideC;
\end{scope}
\begin{scope}[shift={(11,0)}]
\draw[gstyle] (-1,-1) grid (8,8);
\FslideD;
\end{scope}
\end{tikzpicture}
\newcommand{\GslideLines}
{
\draw[wline] (2,0) -- (2,9);
\draw[wline] (3,0) -- (3,9);
\draw[wline] (5,0) -- (5,9);
\draw[wline] (6,0) -- (6,9);
}
\newcommand{\GslideA}
{
\begin{scope}
\fill [fill=\squarecolor, path fading=west] (0,0) rectangle (2,9);
\fill [fill=\squarecolor,path fading=east] (3,0) rectangle (5,9);
\fill [fill=\squarecolor, path fading=west] (3,0) rectangle (5,9);
\fill [fill=\squarecolor,path fading=east] (6,0) rectangle (8,9);
\GslideLines
\end{scope}
}
\newcommand{\GslideB}
{
\def\Akleene{${\mathbf a}{\star}$}
\def\Bkleene{${\mathbf b}{\star}$}
\def\Ckleene{${\mathbf c}{\star}$}
\def\LTkleene{${\mathcal T_1}{\star}$}
\def\RTkleene{${\mathcal T_2}{\star}$}
\GslideA;
\begin{scope}
\Dsquare{2}{0}{\kleene};
\Dsquare{2}{1}{\kleene};
\Dsquare{2}{2}{\Ckleene};
\Dsquare{2}{3}{\Bkleene};
\Dsquare{2}{4}{\Akleene};
\Dsquare{2}{5}{\kleene};
\Dsquare{2}{6}{\LTkleene};
\Dsquare{2}{7}{\LTkleene};
\Dsquare{2}{8}{\kleene};
\Dsquare{5}{0}{\kleene};
\Dsquare{5}{1}{\Ckleene};
\Dsquare{5}{2}{\Bkleene};
\Dsquare{5}{3}{\Akleene};
\Dsquare{5}{4}{\kleene};
\Dsquare{5}{5}{\kleene};
\Dsquare{5}{6}{\RTkleene};
\Dsquare{5}{7}{\RTkleene};
\Dsquare{5}{8}{\kleene};
\GslideLines
\end{scope}
}
\newcommand{\GslideC}
{
\GslideB;
\begin{scope}
\vtile{2}{0};
\vtile{2}{2};
\vtile{2}{4};
\vtile{2}{6};
\vtile{2}{8};
\GslideLines
\end{scope}
}
\newcommand{\GslideD}
{
\begin{scope}[opacity=.4,transparency group]
\node at (4,4.5) [forbidden sign,line width=2ex,minimum size=8cm,draw=red]
{};
\end{scope}
\GslideC;
\begin{scope}
\dvtile{5}{-1};
\dvtile{5}{1};
\dvtile{5}{3};
\dvtile{5}{5};
\dvtile{5}{7};
\GslideLines
\end{scope}
\node[ellipse,fill=white,fill opacity=.4, text opacity=1] at(0,4)
(duplicateinfo)
{Duplicate pair};
\draw[-,color=red,line width=.5mm] (duplicateinfo) -- (2.3,2.5);
\draw[-,color=red,line width=.5mm] (duplicateinfo) -- (5.3,2.5);
}
\newcommand{\GslideE}
{
\begin{scope}[opacity=.7,transparency group]
\node[font=\fontsize{7cm}{7cm},circle,draw=green,line width=2ex,minimum size=8cm,color=green]
at (4,4.5)
{$\checkmark$};
\end{scope}
\GslideC;
\begin{scope}
\dvtile{5}{0};
\dvtile{5}{2};
\dvtile{5}{4};
\dvtile{5}{6};
\dvtile{5}{8};
\GslideLines
\end{scope}
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (9,10);
%--------------------------------
\GslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (9,10);
%--------------------------------
\GslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (9,10);
%--------------------------------
\GslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (9,10);
%--------------------------------
\GslideD;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (9,10);
%--------------------------------
\GslideE;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (9,10);
\GslideA;
\end{scope}
\begin{scope}[shift={(12,0)}]
\draw[gstyle] (-1,-1) grid (9,10);
\GslideB;
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (0,-1) grid (9,10);
\GslideC;
\end{scope}
\begin{scope}[shift={(11,0)}]
\draw[gstyle] (-1,-1) grid (9,10);
\GslideD;
\end{scope}
\begin{scope}[shift={(22,0)}]
\draw[gstyle] (-1,-1) grid (8,10);
\GslideE;
\end{scope}
\end{tikzpicture}
\end{document}
\documentclass[tikz,margin=5em]{standalone}
\usepackage{intcalc,calc}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{amsmath}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{shapes}
\usetikzlibrary{fadings}
\title{Dominosa.Part.III}
\begin{document}
\def\tilecolor{gray}
\def\squarecolor{gray!40!white}
\tikzset{dstyle/.style={line width=0.5 mm,rounded corners,fill=gray,fill opacity=.3}}
\tikzset{snode/.style={rounded corners,fill=\squarecolor,
text opacity=1,fill opacity=1,
minimum size=1 cm,font=\bfseries}}
\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\tikzset{bline/.style={rounded corners,line width=.5mm,color=black}}
\tikzset{darrow/.style={-stealth,line width=.5mm}}
\tikzset{idarrow/.style={stealth-,line width=.5mm}}
\tikzset{gstyle/.style={step=1cm,black,line width=.1mm,opacity=.3}}
\def\tilemargin{.05}
\def\kleene{${\star}$}
\def\numeralA{$\mathbf{1}$}
\def\qkleene{${\mathbf q}{\star}$}
\def\rkleene{${\mathbf r}{\star}$}
\def\cornerLength{5}
\def\tkleene{${\mathcal T}{\star}$}
\def\fkleene{${\mathcal F}{\star}$}
\newcommand*{\vtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\dvtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\htile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\dhtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\square}[3]{
\def\x{#1}
\def\y{#2}
\def\sname{#3}
\node[snode] at (\x+.5,\y+.5) {\sname};
}
\newcommand*{\vspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\square{\xb+0}{\yb+\j}{\kleene};
\square{\xb+1}{\yb+\j}{\numeralA};
\square{\xb+2}{\yb+\j}{\numeralA};
\square{\xb+3}{\yb+\j}{\kleene};
}
}
\newcommand*{\vspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\htile{\xb+0}{\yb+\j};
\htile{\xb+2}{\yb+\j};
}
}
\newcommand*{\hspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\square{\xb+\j}{\yb+0}{\kleene};
\square{\xb+\j}{\yb+1}{\numeralA};
\square{\xb+\j}{\yb+2}{\numeralA};
\square{\xb+\j}{\yb+3}{\kleene};
}
}
\newcommand*{\hspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\vtile{\xb+\j}{\yb+0};
\vtile{\xb+\j}{\yb+2};
}
}
\newcommand{\EslideA}
{
\begin{scope}
\fill [fill=\squarecolor, path fading=west] (0,0) rectangle (4,4);
\fill [fill=\squarecolor, path fading=south] (0,0) rectangle (4,4);
\fill [fill=\squarecolor,path fading=east] (5,0) rectangle (9,4);
\fill [fill=\squarecolor,path fading=south] (5,0) rectangle (9,4);
\fill [fill=\squarecolor,path fading=north] (0,5) rectangle (9,8);
\draw[wline] (0,5) -- (9,5);
\draw[wline] (0,4) -| (4,0);
\draw[wline] (9,4) -| (5,0);
\end{scope}
}
\newcommand{\EslideB}
{
\EslideA;
\begin{scope}
\square{4}{0}{\kleene};
\square{4}{1}{\kleene};
\square{4}{2}{\kleene};
\square{4}{3}{\kleene};
\square{0}{4}{\kleene};
\square{1}{4}{\kleene};
\square{2}{4}{\kleene};
\square{3}{4}{\kleene};
\square{4}{4}{\kleene};
\square{5}{4}{\kleene};
\square{6}{4}{\kleene};
\square{7}{4}{\kleene};
\square{8}{4}{\kleene};
\draw[wline] (0,5) -- (9,5);
\draw[wline] (0,4) -| (4,0);
\draw[wline] (9,4) -| (5,0);
\end{scope}
}
\newcommand{\EslideC}%states
{
\EslideB;
\begin{scope}
\dhtile{3}{4};
\dhtile{4}{4};
\dvtile{4}{3};
\end{scope}
}
\newcommand{\EslideD}%left state
{
\EslideB;
\begin{scope}
\vtile{4}{0};
\vtile{4}{2};
\htile{-1}{4};
\htile{1}{4};
\htile{3}{4};
\htile{5}{4};
\htile{7}{4};
\end{scope}
\draw[darrow] (.5,5.5) -- (3.5,5.5);
\draw[idarrow] (8.5,5.5) -- (5.5,5.5);
\draw[idarrow] (3.5,.5) -- (3.5,3.5);
}
\newcommand{\EslideE}%bottom state
{
\EslideB;
\begin{scope}
\vtile{4}{-1};
\vtile{4}{1};
\vtile{4}{3};
\htile{0}{4};
\htile{2}{4};
\htile{5}{4};
\htile{7}{4};
\end{scope}
\draw[idarrow] (.5,5.5) -- (3.5,5.5);
\draw[idarrow] (8.5,5.5) -- (5.5,5.5);
\draw[darrow] (3.5,.5) -- (3.5,3.5);
}
\newcommand{\EslideF}%right state
{
\EslideB;
\begin{scope}
\vtile{4}{0};
\vtile{4}{2};
\htile{0}{4};
\htile{2}{4};
\htile{4}{4};
\htile{6}{4};
\htile{8}{4};
\end{scope}
\draw[idarrow] (.5,5.5) -- (3.5,5.5);
\draw[darrow] (8.5,5.5) -- (5.5,5.5);
\draw[idarrow] (3.5,.5) -- (3.5,3.5);
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\EslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\EslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\EslideC;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\EslideD;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\EslideE;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,9);
%--------------------------------
\EslideF;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\EslideA;
\end{scope}
\begin{scope}[shift={(12,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\EslideB;
\end{scope}
\begin{scope}[shift={(24,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\EslideC;
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\begin{scope}[shift={(0,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\EslideD;
\end{scope}
\begin{scope}[shift={(12,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\EslideE;
\end{scope}
\begin{scope}[shift={(24,0)}]
\draw[gstyle] (-1,-1) grid (10,9);
\EslideF;
\end{scope}
\end{tikzpicture}
\end{document}
\documentclass[tikz,margin=5em]{standalone}
\usepackage{intcalc,calc}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{amsmath,amssymb}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{relsize}
\usetikzlibrary{shapes}
\usetikzlibrary{fadings}
\title{Dominosa.Part.IV}
\begin{document}
\def\tilecolor{gray}
\def\squarecolor{gray!40!white}
\tikzset{dstyle/.style={line width=0.5 mm,rounded corners,fill=gray,fill opacity=.3}}
\tikzset{snode/.style={rounded corners,fill=\squarecolor,
text opacity=1,fill opacity=1,
minimum size=1 cm,font=\bfseries}}
\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\tikzset{bline/.style={rounded corners,line width=.5mm,color=black}}
\tikzset{darrow/.style={-stealth,line width=.5mm}}
\tikzset{idarrow/.style={stealth-,line width=.5mm}}
\tikzset{gstyle/.style={step=1cm,black,line width=.1mm,opacity=.3}}
\tikzset{checknode/.style = {font=\relsize{#1}}}
\tikzset{descarrow/.style={-,line width=1mm,orange}}
\tikzset{descnode/.style={ellipse,fill=green!20,fill opacity=0.7}}
\def\tilemargin{.05}
\def\kleene{${\star}$}
\def\numeralA{$\mathbf{1}$}
\def\qkleene{${\mathbf q}{\star}$}
\def\rkleene{${\mathbf r}{\star}$}
\def\cornerLength{5}
\def\tkleene{${\mathcal T}{\star}$}
\def\fkleene{${\mathcal F}{\star}$}
\def\wificolor{green!20!blue!10}
\newcommand*{\vtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\dvtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\htile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\dhtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+2-\tilemargin,\y+1-\tilemargin);
}
\newcommand*{\Dsquare}[3]{
\def\x{#1}
\def\y{#2}
\def\sname{#3}
\node[snode] at (\x+.5,\y+.5) {\sname};
}
\newcommand*{\vspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\Dsquare{\xb+0}{\yb+\j}{\kleene};
\Dsquare{\xb+1}{\yb+\j}{\numeralA};
\Dsquare{\xb+2}{\yb+\j}{\numeralA};
\Dsquare{\xb+3}{\yb+\j}{\kleene};
}
}
\newcommand*{\vspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\htile{\xb+0}{\yb+\j};
\htile{\xb+2}{\yb+\j};
}
}
\newcommand*{\hspine}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 1),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {1,...,\length}
{
\Dsquare{\xb+\j}{\yb+0}{\kleene};
\Dsquare{\xb+\j}{\yb+1}{\numeralA};
\Dsquare{\xb+\j}{\yb+2}{\numeralA};
\Dsquare{\xb+\j}{\yb+3}{\kleene};
}
}
\newcommand*{\hspinecover}[3]{
\def\x{#1}
\def\y{#2}
\def\length{#3}
\foreach \i [evaluate=\j using int(\i - 2),
evaluate=\xb using int(\x),
evaluate=\yb using int(\y)]
in {3,...,\length}
{
\vtile{\xb+\j}{\yb+0};
\vtile{\xb+\j}{\yb+2};
}
}
\newcommand{\hwifiback}[2]{
\def\x{#1}
\def\y{#2}
\def\circles{3}
\def\width{2}
\def\height{4}
\def\icircles{{\height / \circles}}
\foreach \i
[evaluate=\i as \j using (\icircles*\i)]
in {1,...,\circles}
{
\node[draw,ellipse,
fill=\wificolor,opacity=.5,
minimum width=\width cm, minimum height=\j cm] at(\x + 1, \y+.5) {};
}
\node[draw,ellipse,
fill=\wificolor,opacity=.4,
minimum width=12 cm, minimum height=12 cm] at(\x + 1, \y+.5) {};
}
\newcommand{\hwififront}[2]{
\def\x{#1}
\def\y{#2}
\def\circles{3}
\def\width{2}
\def\height{4}
\def\icircles{\height / \circles}
\foreach \i
[evaluate=\i as \j using (\icircles*\i)]
in {1}
{
\node[draw,ellipse,
fill=\wificolor,opacity=.5,
minimum width=\width cm, minimum height=1 cm] at(\x + 1, \y+.5) {};
}
}
\newcommand{\vwifiback}[2]{
\def\x{#1}
\def\y{#2}
\def\circles{3}
\def\width{4}
\def\height{2}
\def\icircles{{\width / \circles}}
\foreach \i
[evaluate=\i as \j using (\icircles*\i)]
in {1,...,\circles}
{
\node[draw,ellipse,
fill=\wificolor,opacity=.5,
minimum width=\j cm, minimum height=\height cm] at(\x + .5, \y + 1) {};
}
\node[draw,ellipse,
fill=\wificolor,opacity=.4,
minimum width=12 cm, minimum height=12 cm] at(\x + .5, \y + 1) {};
}
\newcommand{\vwififront}[2]{
\def\x{#1}
\def\y{#2}
\def\circles{1}
\def\width{4}
\def\height{2}
\def\icircles{{\width / \circles}}
\foreach \i
[evaluate=\i as \j using (\icircles*\i)]
in {1,...,\circles}
{
\node[draw,ellipse,
fill=\wificolor,opacity=.5,
minimum width=1 cm, minimum height=\height cm] at(\x + .5, \y + 1) {};
}
}
\begin{tikzpicture}[]
\draw[gstyle] (0,0) grid (5,5);
\begin{scope}[shift={(0,0)}]
\vwifiback{0}{0};
\end{scope}
\begin{scope}[shift={(5,0)}]
\hwifiback{0}{0};
\end{scope}
\end{tikzpicture}
\newcommand{\HslideClauseLines}
{
\draw[wline] (0,5) -- (9,5);
\draw[wline] (0,4) -| (4,0);
\draw[wline] (9,4) -| (5,0);
}
\newcommand{\HslideClause}
{
\begin{scope}
\foreach \i in {0,...,4}
\Dsquare{4}{\i}{\kleene};
\foreach \i in {0,...,8}
\Dsquare{\i}{4}{\kleene};
\end{scope}
\begin{scope}
\fill [fill=\squarecolor, path fading=west] (0,0) rectangle (4,4);
\fill [fill=\squarecolor, path fading=south] (0,0) rectangle (4,4);
\fill [fill=\squarecolor, path fading=east] (5,0) rectangle (9,4);
\fill [fill=\squarecolor, path fading=south] (5,0) rectangle (9,4);
\fill [fill=\squarecolor, path fading=north] (0,5) rectangle (9,8);
\HslideClauseLines;
\end{scope}
}
\newcommand{\HslideCordlessClause}
{
\HslideClause;
\begin{scope}
\fill [fill=\squarecolor, path fading=north] (-7,5) rectangle (0,8);
\fill [fill=\squarecolor, path fading=south] (-7,1) rectangle (0,4);
\fill [fill=\squarecolor, path fading=north] (9,5) rectangle (16,8);
\fill [fill=\squarecolor, path fading=south] (9,1) rectangle (16,4);
\fill [fill=\squarecolor, path fading=west] (1,-7) rectangle (4,0);
\fill [fill=\squarecolor, path fading=east] (5,-7) rectangle (8,0);
\end{scope}
\hwifiback{-6}{4};
\hwifiback{13}{4};
\vwifiback{4}{-6};
\begin{scope}
\foreach \i in {-7,...,-1}
\Dsquare{\i}{4}{\kleene};
\foreach \i in {9,...,15}
\Dsquare{\i}{4}{\kleene};
\foreach \i in {-7,...,-1}
\Dsquare{4}{\i}{\kleene};
\end{scope}
\begin{scope}
\draw[wline] (-7,5) -- (0,5);
\draw[wline] (-7,4) -- (0,4);
\draw[wline] (9,5) -- (16,5);
\draw[wline] (9,4) -- (16,4);
\draw[wline] (4,0) -- (4,-7);
\draw[wline] (5,0) -- (5,-7);
\HslideClauseLines;
\end{scope}
\hwififront{-6}{4};
\hwififront{13}{4};
\vwififront{4}{-6};
}
\newcommand{\HslideA}
{
\HslideClause;
\begin{scope}
\end{scope}
}
\newcommand{\HslideB}
{
\HslideCordlessClause;
\begin{scope}
\node[descnode,scale=2] at (-3,-3) (hspotsdesca) {Hotspots};
\node[descnode,scale=2] at (11,-3) (hspotsdescb) {Hotspots};
\node[descnode,scale=2] at (4,8) (clausesdesc) {Clause};
\draw[descarrow] (clausesdesc) -- (4.5,5.5);
\draw[descarrow] (hspotsdesca) -- (-5,4.5) (hspotsdesca) -- (4.3,-5);
\draw[descarrow] (hspotsdescb) -- (14,4.5) (hspotsdescb) -- (4.7,-5);
\end{scope}
}
\newcommand{\drawVarHotspot}{
\begin{scope}
\hwifiback{0}{0};
\end{scope}
}
\newcommand{\drawvar}[4]{
\begin{scope}
\def\aleftstart{#1}
\def\arightend{#2}
\def\ai{#3}
\def\ay{#4}
\foreach \k in {1,...,3}
{
\def\rndx{\aleftstart+ (rnd * (\arightend-\aleftstart))}
\foreach \j
[evaluate=\j as \rndxeval using int(\j+\rndx)]
in {0}
{
\node[scale=8] at ({\rndxeval}, \ay+.5) (hx\ai-\k) {};
%\ifnum\i>5
\begin{scope}[shift={(\rndxeval,\ay)}]
\drawVarHotspot;
\end{scope}
%\fi
}
}
\draw[wline] (\aleftstart,\ay) -- (\arightend,\ay);
\draw[wline] (\aleftstart,\ay+1) -- (\arightend,\ay+1);
\draw[fill=\squarecolor] (\aleftstart,\ay) rectangle (\arightend,\ay+1);
\node[scale=8] at (\arightend + 5, \ay+.5) {$x_\i$};
\end{scope}
}
\newcommand{\HslideC}
{
\def\bottomstart{5}
\def\leftstart{10}
\def\rightend{105}
\def\variables{6}
\def\topend{90}
\draw[line width=1cm,rounded corners] (0,0) rectangle (\rightend+10+5,\topend);
\begin{scope}[shift={(10,45)},xscale=1.3]
\foreach \i
[evaluate=\i as \x using int(8+\i*20)]
in {0,...,3}
{
\foreach \j
[evaluate=\j as \y using int(8+\j*15)]
in {0,...,1}
{
\begin{scope}[shift={(\x,\y)},scale=.8]
\HslideCordlessClause;
\end{scope}
}
}
\end{scope}
\begin{scope}
\pgfmathsetseed{3}
\foreach \i
[evaluate=\i as \y using int(\bottomstart+(\i-1)*4)]
in {1,...,\variables}
{
\drawvar{\leftstart}{\rightend}{\i}{\y};
}
\end{scope}
\node[descnode,scale=8] at (13,37) (hotspotsdesc) {Hotspots};
\node[descnode,scale=10] at (50,85) (clausesdesc) {Clauses};
\draw[descarrow] (clausesdesc) -- (24.5,73) (clausesdesc) -- (103,73);
\draw[descarrow] (hotspotsdesc) -- (20,46)
(hotspotsdesc) -- (16,51)
(hotspotsdesc) -- (46,46)
(hotspotsdesc) -- (72,46)
(hotspotsdesc) -- (hx6-1) (hotspotsdesc) -- (hx6-2)
(hotspotsdesc) -- (hx5-1) (hotspotsdesc) -- (hx5-2)
(hotspotsdesc) -- (hx4-1) (hotspotsdesc) -- (hx4-2);
\draw [decorate,decoration={brace,amplitude=1cm},align=left,line width=5mm]
(-2,\bottomstart) -- (-2,\variables*4+2)
node[midway, left, font=\footnotesize, xshift=-1em,scale=8]
{$\mathcal O\left(|\mathbf{x}|\right)$\\variables};
\draw [decorate,decoration={brace,amplitude=1cm},align=left,line width=5mm]
(13,\topend+2) -- (\rightend+10,\topend+2)
node[midway, above, font=\footnotesize, yshift=1em,scale=8]
{$\mathcal O\left(\left|\Phi(\mathbf{x})\right|\right)$ clauses};
}
\begin{tikzpicture}[]
\draw[gstyle] (-1,-1) grid (10,8);
%--------------------------------
\HslideA;
\end{tikzpicture}
\begin{tikzpicture}[]
\draw[gstyle] (-8,-8) grid (17,8);
%--------------------------------
\HslideB;
\end{tikzpicture}
\begin{tikzpicture}[]
%--------------------------------
\HslideC;
\end{tikzpicture}
\end{document}
\documentclass[tikz,margin=5em]{standalone}
\usepackage{intcalc,calc}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage{amsmath,amssymb}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathreplacing}
\usepackage{relsize}
\usetikzlibrary{shapes}
\usetikzlibrary{fadings}
\title{Dominosa.V}
\begin{document}
\def\tilecolor{gray}
\def\squarecolor{gray!40!white}
\tikzset{dstyle/.style={line width=0.5 mm,rounded corners,fill=gray,fill opacity=.3}}
\tikzset{snode/.style={rounded corners,fill=\squarecolor,
text opacity=1,fill opacity=1,
minimum size=1 cm,font=\bfseries}}
\tikzset{wline/.style={rounded corners,line width=1mm,color=blue!40!black}}
\tikzset{bline/.style={rounded corners,line width=.5mm,color=black}}
\tikzset{brect/.style={fill=black}}
\tikzset{darrow/.style={-stealth,line width=.5mm}}
\tikzset{idarrow/.style={stealth-,line width=.5mm}}
\tikzset{gstyle/.style={step=1cm,black,line width=.1mm,opacity=.3}}
\tikzset{checknode/.style = {font=\relsize{#1}}}
\tikzset{descarrow/.style={-,line width=1mm,orange}}
\tikzset{descnode/.style={ellipse,fill=green!20,fill opacity=0.7}}
\def\tilemargin{.05}
\def\kleene{${\star}$}
\def\numeralA{$\mathbf{1}$}
\def\qkleene{${\mathbf q}{\star}$}
\def\rkleene{${\mathbf r}{\star}$}
\def\cornerLength{5}
\def\tkleene{${\mathcal T}{\star}$}
\def\fkleene{${\mathcal F}{\star}$}
\def\tvalue{$\mathcal T$}
\def\fvalue{$\mathcal F$}
\def\wificolor{green!20!blue!10}
\newcommand*{\vtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\dvtile}[2]{
\def\x{#1}
\def\y{#2}
\draw[dstyle,dashed] (\x+\tilemargin,\y+\tilemargin) rectangle (\x+1-\tilemargin,\y+2-\tilemargin);
}
\newcommand*{\htile}[2]{
\def\x{#1}
\def\y{#2}
</