CS534 Spring 2019: Logic Based Systems with Minesweeper

Slides:



Advertisements
Similar presentations
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Advertisements

Introduction to Proofs
CPSC 121: Models of Computation Unit 6 Rewriting Predicate Logic Statements Based on slides by Patrice Belleville and Steve Wolfman.
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Mar, 4, 2015 Slide credit: some slides adapted from Stuart.
Artificial Intelligence Knowledge-based Agents Russell and Norvig, Ch. 6, 7.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Class Project Due at end of finals week Essentially anything you want, so long as its AI related and I approve Any programming language you want In pairs.
Minesweeper is a game of logic. It originated from “Relentless Logic,” which was written by Conway, Hong, and Smith around In Relentless Logic, the.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
Knowledge in intelligent systems So far, we’ve used relatively specialized, naïve agents. How can we build agents that incorporate knowledge and a memory?
Let remember from the previous lesson what is Knowledge representation
Ken Bayer, Josh Snyder, and Berthe Y. Choueiry Constraint Systems Laboratory University of Nebraska-Lincoln A Constraint-Based Approach to Solving Minesweeper.
Inference is a process of building a proof of a sentence, or put it differently inference is an implementation of the entailment relation between sentences.
Introduction to Proofs
MATH 224 – Discrete Mathematics
March 3, 2015Applied Discrete Mathematics Week 5: Mathematical Reasoning 1Arguments Just like a rule of inference, an argument consists of one or more.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
Class Project Due at end of finals week Essentially anything you want, so long as its AI related and I approve Any programming language you want In pairs.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
1 Logical Agents CS 171/271 (Chapter 7) Some text and images in these slides were drawn from Russel & Norvig’s published material.
LDK R Logics for Data and Knowledge Representation Propositional Logic: Reasoning First version by Alessandro Agostini and Fausto Giunchiglia Second version.
CS6133 Software Specification and Verification
1 The Wumpus Game StenchBreeze Stench Gold Breeze StenchBreeze Start  Breeze.
CPSC 422, Lecture 21Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 21 Oct, 30, 2015 Slide credit: some slides adapted from Stuart.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 15: Intractable Problems (Smiley.
1 UNIT-3 KNOWLEDGE REPRESENTATION. 2 Agents that reason logically(Logical agents) A Knowledge based Agent The Wumpus world environment Representation,
Section 1.7. Section Summary Mathematical Proofs Forms of Theorems Direct Proofs Indirect Proofs Proof of the Contrapositive Proof by Contradiction.
Artificial Intelligence Logical Agents Chapter 7.
Presented by: Alon Dean Ron Moisescu Supervised by: Dr. Rachel Ben-Eliyahu - Zohary.
Lecture 2: Proofs and Recursion. Lecture 2-1: Proof Techniques Proof methods : –Inductive reasoning Lecture 2-2 –Deductive reasoning Using counterexample.
The Foundations: Logic and Proofs
Valid and Invalid Arguments
Axiomatic Number Theory and Gödel’s Incompleteness Theorems
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Thinking Critically 1.1 An Introduction to Problem Solving
Monte Carlo simulation
Introduction The two-sample z procedures of Chapter 10 allow us to compare the proportions of successes in two populations or for two treatments. What.
Knowledge and reasoning – second part
EA C461 – Artificial Intelligence Logical Agent
Chapter 25 Comparing Counts.
CS 416 Artificial Intelligence
Christopher Hodgson and Gregory Tyler Loftis
The Foundations: Logic and Proofs
Analysis and design of algorithm
Logical Agents Chapter 7.
Artificial Intelligence
Propositional Logic.
Artificial Intelligence: Logic agents
Midterm Discussion.
adapted from Recursive Backtracking by Mike Scott, UT Austin
Knowledge and reasoning – second part
Computer Security: Art and Science, 2nd Edition
Logical Agents Chapter 7.
Metatheorems Computational Logic Lecture 8
Chapter 26 Comparing Counts.
CS 416 Artificial Intelligence
Knowledge Representation I (Propositional Logic)
Knowledge Representation
Foundations of Discrete Mathematics
CPSC 121: Models of Computation
Propositional Logic CMSC 471 Chapter , 7.7 and Chuck Dyer
Chapter 26 Comparing Counts Copyright © 2009 Pearson Education, Inc.
ECE 352 Digital System Fundamentals
CMSC 471 Fall 2011 Class #10 Tuesday, October 4 Knowledge-Based Agents
Chapter 26 Comparing Counts.
Lecture 23: Computability CS200: Computer Science
Introducing Natural Deduction
Logical Agents Prof. Dr. Widodo Budiharto 2018
Presentation transcript:

CS534 Spring 2019: Logic Based Systems with Minesweeper Showcase by: Steven McAteer, Alex Perucic, Robert Curtis, William Schwartz Showcasing work by Duke on Mini Mine Sweeper and Drew Roos on Minesweeper

References [1] Russell, S., Norvig, P., & Davis, E. (2010). Artificial intelligence : a modern approach (3rd ed.). Upper Saddle River, NJ: Prentice Hall. [2] Becerra, D. (2019). Algorithmic approaches to playing Minesweeper. [online] dash.harvard.edu. Available at: https://dash.harvard.edu/bitstream/handle/1/14398552/BECERRA-SENIORTHESIS-2015.pdf?sequence=1 [Accessed 3 Feb. 2019]. [3] Richard Kaye. Minesweeper is NP-complete. The Mathematical Intelligencer, 22(2): 9–15, 2000. [4] Allan Scott, Ulrike Stege, and Iris van Rooij. Minesweeper may not be NP-complete but is hard nonetheless. The Mathematical Intelligencer, 33(4):5–17, 2011. [5] Tomasi, C. (2006). Mini Mine Sweeper. [online] Www2.cs.duke.edu. Available at: https://www2.cs.duke.edu/courses/spring06/cps102/notes/sweeper.pdf [Accessed 3 Feb. 2019]. [6] Roos, D. (2013). Minesweepr. [online] Mrgris.com. Available at: https://mrgris.com/projects/minesweepr/ [Accessed 3 Feb. 2019].

Agenda Definition Minesweeper Background Automating Minesweeper Propositional Logic Predicate Logic Demo

Definition Logic Agent: In which we design agents that can form representations of a complex world, use a process of inference to derive new representations about the world, and use these new representations to deduce what to do.[1] looking at a logic system since the agent and the game are involved

Minesweeper Background

Image from www.freeminesweeper.org Background Player clicks on a square Specific number of mines on the board Numbers show the number of mines nearby Player loses if a mine is clicked Player wins if they uncover all squares without hitting mine In fact, Minesweeper is in a class of mathematically difficult problems known as co-NP-complete [2][3][4]. little background on minesweeper basic game click on squares, try to find and not explain co-np-complete https://www.phil.pku.edu.cn/cllct/ann_attachments/np.pdf https://link.springer.com/article/10.1007/s00283-011-9256-x Image from www.freeminesweeper.org

Automating Minesweeper 3x3 Board with exactly 1 Mine

Here we see the possible mine configurations for the mini minesweeper game. After revealing the first square, there are 3 possible positions of the mine if the square is 1, and 5 if the square is 0. We need a mathematical way of representing these positions in order to automate the solving process. Image from Mini Mine Sweeper [5]

Images and text from Mini Mine Sweeper [5] Propositional Logic 1 2 3 1 2 3 We can use propositional logic to infer the location of the mine with limited starting information. This is done by creating 4 base assumptions that cover all possible locations of the mine relative to the board state, and then applying the rules of minesweeper to the base assumptions, until we infer a conclusion. We will go over the game rules in detail in a later slide. Images and text from Mini Mine Sweeper [5]

There is a mine at Row 2, Column 1 Propositional Logic 1 2 3 (1,2) (1,3) 1 2 3 = c ¬d b → d c → a ∨ b We apply game rules to create theorems: a ∨ b ¬d → ¬b ¬b a (2,1) (2,2) (2,3) We start with our base assumptions, and then we apply game rules to reach certain conclusions about the state of the board. In 1, we state that there is a mine in one of the squares adjacent to square at row1, column 2. We know this is true since we have already revealed a '1' on the board at that location. We also know d is not true, since we have revealed a 0 at that location. In assumption 3, we state that if b is true, then d also has to be true, since if there is a mine at either row 2, column 2, or row 2, column 3, that means that there is a mine adjacent to row 1, column 3. Finally, in the 4th assumption, we state that if there is a mine in one of the squares adjacent to row 1, column 2, that means that the mine could be in any column of row 2. By applying game rules, we reach theorems that allow us to find out the position of the mine. In theorem 1, we know for sure that the mine is in the second row. In theorem 2, we know that if there is no adjacent mine to row 1, column 3, the mine can't be in row 2, column 2 or column 3. In theorem 3, we know that the mine cannot be in row 2, column 2 or row 2, column 3 Finally, in theorem 4 we conclude that the only valid position of the mine is in row 2, column 1 Through propositional logic, we discover the position of the mine has to be at row 2, column 1. There is a mine at Row 2, Column 1 Images and text from Mini Mine Sweeper [5]

Existence Axiom: Mines where m13 = mine at row 1, column 3 1 2 3 1 2 3 States that there is exactly one mine on the board and none of the start square https://www2.cs.duke.edu/courses/spring06/cps102/notes/sweeper.pdf Images and text from Mini Mine Sweeper [5]

Images and text from Mini Mine Sweeper [5] Axioms: Adjacencies 1 2 3 a11 = there is a mine adjacent to the square at row 1, column 1 1 2 3 We then need to describe adjacency: there is a mine in the square at row 1, column 2 if and only if the following two facts are true. First, there is a mine adjacent to each of the following squares: row 1, column 1; row 1, column 3; row 2, column 1; row 2, column 2; row 2, column 3. Second, there are zero mines adjacent to each of the following squares: row 3, column 1; row 3, column 2; row 3, column 3. Images and text from Mini Mine Sweeper [5]

A Problem 1 2 3 1 2 3 Mines and adjacency axioms are not enough 1 2 3 Mines and adjacency axioms are not enough a11 → we infer that m12 m21 m22 , that there is a mine next to the start square We do not know which to pick, have to ask for new axiom Must ask for one from the game keeper Not part of logical inference 1 2 3 Steve Even though we have these axioms, they don’t give us enough info We can narrow down to a certain point, but can’t decide further Need to ask the game and pick a random square out of those three Image and text from Mini Mine Sweeper [5]

Logical Equivalences & Inferences Steve These are the logical equivalences and inferences we are using Each rule can be used to narrow down choices at each step Not going to step through the sentences (too much time) Image from Mini Mine Sweeper [5]

Example 1 2 3 1 2 3 Start with the existence axiom: Mine must be somewhere other than the start square Find adjacency axioms whose right side contains = true and false These adjacency axioms fit the description: 1 2 3 1 2 3 Steve Start with the given that there is one mine on the board (not at the start square) From there, go to list of adjacency axioms and fine the one that matches 1 and 0. The following fit the description Image from Mini Mine Sweeper [5] Images and text from Mini Mine Sweeper [5]

Example Cont. 1 2 3 1 2 3 Need to prove/be told by game that don’t have a mine Use elimination rule to infer that the following are false: From here, we have one left: 1 2 3 1 2 3 Steve We know that m12 and m13 don’t have a mine because they gamekeeper uncovered them for us By using one of the previous rules (elimination) we infer that all of these axioms are false One left Images and text from Mini Mine Sweeper [5]

Example Cont. 1 2 3 1 2 3 Now, we know where the mine is: Check the mine axiom: Can infer that all other squares are safe, we win the game 1 2 3 1 2 3 Steve We know the mine is at this location now Double check the mine axiom Can infer we win Images and text from Mini Mine Sweeper [5]

Predicate Logic (first order logic) Assuming 3x3 board with 1 mine There exists a mine somewhere on the board that is not the starting location [5]. M(i,j) means “there is a mine in the square at row i and column j.” [5] If there is a mine in a square then there is not a mine adjacent to it.[5] same as earlier rules much shorter though more complex differs from propositional logic by introducing variables go over rules Images and text from Mini Mine Sweeper [5]

Predicate Logic (first order logic) If there is a mine in a square then the adjacent squares to the mine are adjacent to a mine.[5] A(i,j) means “there is a mine in a square adjacent to the square at row i and column j.” [5] If there is no mines in a square, the adjacent squares are not adjacent to a mine.[5] go over rules These rules are less lengthy than the equivalent propositional logic rules, though they are harder to interpret and harder to program Images and text from Mini Mine Sweeper [5]

Implementation of Minesweeper Each rule represents information gleaned from the uncovered cells of the board. A single Rule consists of a set of cells, along with how many mines are to be found among that set. So for a given uncovered cell (say we uncovered a 3), we'd generate: Rule(3, [set of cells adjacent to the uncovered cell]). Board the rules are, the number of adjacent mines, followed by the adjacent squares. on the right we have the board, so the first rule, for column 3 row 1 will be Rule(1, [A, B]) as we will see on the next slide Image and text from minesweepr [6]

Implementation of Minesweeper Function Board minesweeper.solve([ Rule(1, ['A', 'B']), Rule(2, ['A', 'B', 'C']), Rule(3, ['B', 'C', 'D']), Rule(2, ['C', 'D', 'E']), Rule(2, ['D', 'E', 'F', 'G', 'H']), Rule(1, ['G', 'H', 'I']), Rule(1, ['H', 'I']), ], MineCount(total_cells=85, total_mines=10)) this is an implementation of a minesweeper AI that uses logic similar to the logic previously above. in this implementation mine sweeper.solve takes a list of rules, and the rules are, the number of adjacent mines, followed by the adjacent squares. the program then predicts the likelihood that each of the squares is a mine, to come up with the best next move. the prediction is a permutation that counts up the possible board configurations in which the current square is a bomb. https://github.com/mrgriscom/minesweepr/ Returns {'A': 0.0, 'B': 1.0, 'C': 1.0, 'D': 1.0, 'E': 0.0, 'F': 0.0779, 'G': 0.0, 'H': 0.9221, 'I': 0.0779, None: 0.0779} 10x10, 10 mines Image and text from minesweepr [6]

Live Demo https://mrgris.com/projects/minesweepr/demo/player/ Success Rate As the board increases and the number of mines increases that chances that we will have to guess where the next mine is also increases. this guessing is what makes this game impossible to win everytime, but we can have a very high success rate.