Deductive Search for Logic Puzzles Cameron Browne Imperial College London South Kensington, UK [email protected] Abstract—Deductive search (DS) is a breadth-first, depth- another! 9or example, in a comparison of 4=8 difficult Sudoku limited propagation scheme for the constraint-based solution puzzles, there was no agreement in the ,ve examples that three of deduction puzzles, using simple logic operations found in popular solvers 7>.?1, S@ and SU@A%<$3 each rated most standard constraint satisfaction solvers. It attempts to emulate difficult -4/! the processing limits experienced by human solvers, and, to some extent, the process by which they solve such problems. 1! Mathematical Models2 Puzzles may be abstracted to mathe- Any solution deduced by DS is guaranteed to be correct and matical models and solved using standard constraint satisfac- unique. Further, it provides an estimate of the deducibility of tion problem (CSP) [4], Boolean satisfiability (SA$3 [5], binary a given problem for human solvers and offers new ways of decision diagram (BDD) -B/ or other optimisation techniques. understanding deduction puzzles. Its performance is tested on These approaches are general, well studied and understood, a number of problem domains including %apanese logic puzzles, and typically efficient at finding solutions. However, the' a traditional logic puzzle, and a geometric placement puzzle. do not necessarily represent the player’s understanding of a given puzzle. Firstly, the mapping of the problem to a I! I#$%&DUC$I&# mathematical model can rephrase it in terms that a human Sudoku is currently rivalling the crossword as the world’s might not recognise (e.g. D×D Sudoku maps to =1D binary SA$ most popular “pencil and paper puzzle”, largely because it is variables -8/3! Secondly, these approaches tend to be recursive language-neutral and can be solved using pure logic without in nature to arbitrary search depths, and not subject to the same the need for culture-specific knowledge -./! It is representative processing limitations experienced by players. of a family of logic puzzles, popularised by Japanese publisher Nikoli and hence called called Japanese logic puzzles [2], that A. Motivation are characterised by the following properties: Recursive structures are hard for humans to model men- .3 Single player! tally -=/! Evidence from the field of psycholinguistics suggests 13 Simple rules. a mental limit of two levels of embedding (2-LoE) in natural 43 Single unique solution. language processing -F/! Such sentences, constructed with 63 Can be solved by deduction (not guesswork). two recursive levels of embedding of grammatical rules, are 83 Culture-independent and language-neutral. occasionally found in written form but almost never in natural discourse, and there have been no known cases of natural 9or example, Figure . shows Slitherlink, a typical Japanese 3-LoE sentences in over a century! Each level of recursion logic puzzle, in which the player must draw edges on a grid requires mental storage of embedding points for future back- to form a single non-self-intersecting closed path, such that tracking, which quickly exhausts short-term memory -=/! the number of edges around each numbered cell equals that number! ;e will refer to such puzzles as deduction puzzles! ;e posit that a similar limit applies to mental recursion employed by players when solving deduction puzzles, as the' must mentally store embedding points (and an' resulting 3 1 3 1 consequents) of lookahead moves. Further, we believe that this 2 2 limit should be respected by an' automated solver that aims to 3 2 2 3 2 2 emulate the human puzzle-solving process with an' accurac'! ;ith this in mind, we propose a new approach for solving deduction puzzles called deductive search (DS). This is a Fig. .! < Slitherlink challenge (left) and its solution (right). breadth-first, depth-limited, constraint-based approach based on known techniques, but implemented to model puzzles as There exist various techniques for solving deduction puz- directly as possible and use simple logic operations that a zles, which can be divided into two broad categories: player would typically emplo' under similar computational .! Heuristic Approaches2 These solvers use heuristics, rules, limitations. The aim of DS is to determine the deducibility of strategies or patterns specific to the given domain, usually a given puzzle challenge for humans. The following sections modelling approaches that players (i.e. human solvers) would describe the algorithm and its performance on a variety of apply! Such solvers are tied closely to their given domain, deduction puzzles. and can require expert knowledge about the domain to operate II! D@DUC$IG@ S@<%CC successfully! Difficulty ratings derived from heuristic solvers can be unreliable, as the' may not implement all strategies, Deductive search (DS) is an iterative constraint-based ap- and strategies that one player finds difficult could be easy for proach for solving puzzles using simple logic operations in a 978-1-4673-5311-3/13/$31.00 ©2013 IEEE breadth-first, depth-limited manner! It is strictly monotonic in 2 2 H operation, as an' information deduced during the search cannot X 0 3 3 be unlearnt or overridden. The assumed model is as follows. i 2 2 A. Model 3 3 Each domain is modelled as a CSP involving a set of 2 2 3 3 variables X = {X1, X2, . , Xn} with integer values in their H1 respective domains D = {d1, d2, . , dn}, where DXi is the domain of possible values for Xi! Each variable represents a decision to be made and must have exactly one correct Fig. 1! Shaving of value I from Xi due to contradictory hypothesis H0! value, otherwise X does not constitute a deduction puzzle. The instantiation of a variable Xi to value v is denoted Xi · v and the elimination of value v from Xi is denoted Xi\v! I is eliminated from Xi, and Xi resolves to the only remaining The current state S represents the set of values X at value (1, right). a given point. The initial state S0 is called the challenge! Shaving, in this context, is the integer-based counterpart of C = {c1, c2, . , cm} is a set of constraints that every state the failed literal rule used to propagate binary SA$ variables S must satisfy, where the constraint Ci is defined on a subset in the standard DPLL algorithm -.I/! The opposite operation of variables {X 1 , X 2 , . , X } ⊂ X, where a is the arity i i iaj j (instantiating values whose elimination would cause a contra- of constraint Cj! < variable Xi is arc-consistent with another diction) was found to have little benefit in practice for DS, so ∗ variable Xj if each value v ∈ Xi is consistent with at least is not implemented here. ∗ one value w ∈ Xj ! 3. Agreement. or each unresolved variable Xi! if every The subset of unresolved variables for a given state S is potential instantiation v results in the instantiation of any w ∗ denoted S , and the subset of remaining values available to a in Xj (following simplification), then Xj is instantiated to w2 ∗ ∗ ∗ given variable Xi is denoted Xi ! |X|, |Xi | and |S | denote ∗ the cardinality of the respective sets. < state S is solved when (∀v ∈ Xi : Xi · v ⇒ Xj · w) ⇒ Xj ← Xj · w 713 all variables are resolved to their correct value (i.e. S∗ = ∅3 and the instantiation of X is consistent with C! Conversely! if no potential instantiation of any v in Xi results in the instantiation of any w in Xj (following simpli- B. Operation fication), then w is eliminated from Xj2 ∗ Given a state X, variable updates (instantiations and elim- (�v ∈ Xi : Xi · v ⇒ Xj · w) ⇒ Xj ← Xj\w 743 inations) are propagated iteratively in three ways. Galues are therefore updated if that update would occur as 1. Simplification. or each update to a variable Xi! perform a result of every possible instantiation of some other variable. updates to other variables in each constraint Cj : Xi ∈ Cj 9or example, Figure 4 shows this process applied to a variable required to maintain arc-consistency. Xi (dotted, left) in another 4×1 Slitherlink example. This operation simplifies variables to maintain arc- consistenc' within the domain of each constraint C of which 2 2 j H Xi is a member! The exact simplification performed in each X 0 1 1 case depends on the type of constraint. 9or example, the i instantiation of a cell to value v in Sudoku means that v can be 2 2 eliminated from all other cells in its row, column and sub-grid. 1 1 2. Shaving. or each unresolved variable Xi! any available 2 2 value v whose instantiation would create a contradiction ⊥ H 1 1 (following simplification) is eliminated2 1 ∗ (∃v ∈ Xi : Xi · v ⇒⊥) ⇒ Xi ← Xi\v 7.3 Fig. 4! Instantiation of other values due to agreement with Xi! Invalid instantiations that would result in a contradiction are shaved from their variables -D/! 9or example, consider the Again, the two possible hypotheses for Xi are Xi = 0 7no edge3 and Xi = 1 7edge3! However, this time the focus decision Xi (dotted) in the 4×2 Slitherlink example shown in is on the simplifications resulting from Xi rather than Xi Figure 1! There are two values available to Xi, which yields two possible hypotheses: itself (Figure 3, middle). Since both hypotheses result in the same three variables being simplified to . (edge), then these H0 : Xi = 0 (no edge) variables can safely be instantiated to this value (right), even though no conclusions can be drawn about Xi itself. H1 : Xi = 1 (edge) Simplification depends on the constraints being modelled, H0 leads to a contradiction (following simplification) as the whereas the shaving and agreement steps are standard logic hint with value 4 is violated (top row).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-