This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

SAT as a game

Olivier Bailleux Université de Bourgogne Franche-Comté
Abstract

We propose a funny representation of SAT. While the primary interest is to present propositional satisfiability in a playful way for pedagogical purposes, it could also inspire new search heuristics.

1 The colored tokens game

The game board consists of boxes containing round and square tokens of different colors. For each color, the player must remove either all the square tokens or all the round ones. The game is won if there is at least one token in each box. The result is the same regardless of the order in which the tokens are removed. It depends only on the shape removed for each color.

Refer to caption
Figure 1: An example of game play.

The initial configuration (boxes and tokens) is said to be an instance of the game. It is said to be feasible if and only if it admits at least one solution.

2 SAT representation

2.1 SAT

In the context of propositional logic, a literal is either a propositional variable vv or its negation ¬v\neg v, a clause is a disjunction of literals l1lml_{1}\vee\cdots\vee l_{m}, and a CNF formula is a conjunction of clauses q1qnq_{1}\wedge\cdots\wedge q_{n}. An interpretation of a formula Σ\Sigma is an assignment of a truth value (true or false) to each variable occurring in Σ\Sigma. An interpretation is said to satisfy a formula Σ\Sigma if and only if it evaluates this formula to true according to the standard semantic of the operators ¬,,\neg,\vee,\wedge. A formula is said to be satisfiable if and only if there exists at least one interpretation that satisfies it.

SAT is the problem of determining whether a given CNF formula is satisfiable or not. For more information, see, for example [1].

2.2 Representing a SAT instance with the colored tokens game

SAT reduces to the colored tokens game as follows. Each box corresponds to a clause and each color corresponds to a variable. Any square token represents a positive literal, and any round token represents a negative literal.

For example, the following formula encodes the initial configuration of the figure 1. The variable rr stands for the color red, bb for blue, pp for purple, and yy for yellow, respectively.

(rb¬p)(¬rb¬p)(r¬b¬p)(¬r¬b¬p)(py)(r¬y)(b¬y)(r\vee b\vee\neg p)\wedge(\neg r\vee b\vee\neg p)\wedge(r\vee\neg b\vee\neg p)\wedge(\neg r\vee\neg b\vee\neg p)\wedge(p\vee y)\wedge(r\vee\neg y)\wedge(b\vee\neg y)

Clearly, any interpretation satisfying the resulting formula (if applicable) corresponds to a solution of the underlying game instance.

3 A variant

Here is a variant of the game based on alternative rules : the player removes one token at a time and can either remove a square or a round token of any color. The game ends when each box contains exactly one token. The player wins if and only if all the tokens of each color have the same shape.

SAT reduces to this variant in the same way as to the original game thanks to the following property.

Proposition 1.

Any instance of the variant is feasible if and only if the corresponding instance of the original game is feasible.

Sketch of the proof.
  1. 1.

    Any solution of the variant can be obtained from a solution of the original problem by removing all tokens but one from each box.

  2. 2.

    Given a solution svs_{v} of the variant, a solution of the original game can be obtained in the following way: from the initial state, for each color, the tokens of the shape occurring in svs_{v} are kept, and the other ones are removed.

4 Interests of the game and related works

There are several examples of links between SAT and games in the literature. For example, SAT encodings for the popular Sudoku game are presented in [3] and [2]. Conversely, the famous Candy Crush game was proved to be NP-hard thanks to a reduction from SAT in [4]. There is also a WEB application, ”The SAT game” from Olivier Roussel (CRIL université d’Artois), which proposes to solve a SAT instance represented as an integer matrix where each line is a clause. Variables and literals are represented by an integers in the same way as in the largely used DIMACS format.

The aim of the colored tokens representation is to be easier to grasp for humans. It could be used for the vulgarization of propositional satisfiability, but also to analyze the strategies of the best players and to use them in designing new search heuristics or branching rules. The colored tokens representation can also inspire new search heuristics by itself. For example, a local search solver inspired from the variant presented section 3 could explore a search space where each configuration selects only one literal per clause, with a cost function which penalizes the variables occurring both in positive and negative forms.

References

  • [1] Armin Biere, Marijn Heule, and Hans van Maaren. Handbook of satisfiability, volume 185. ios press, 2009.
  • [2] Gihwon Kwon and Himanshu Jain. Optimized cnf encoding for sudoku puzzles. In Proc. 13th International Conference on Logic for Programming Artificial Intelligence and Reasoning (LPAR2006), pages 1–5, 2006.
  • [3] Inês Lynce and Joël Ouaknine. Sudoku as a SAT problem. In International Symposium on Artificial Intelligence and Mathematics (ISAIM 2006), Fort Lauderdale, Florida, USA, January 4-6, 2006, 2006.
  • [4] Toby Walsh. Candy crush is np-hard. CoRR, abs/1403.1911, 2014.