Lecture 5 Knights and Knaves.. Administration Show hand in form. Show plagiarism form. Any problems with coursework? Google knight and knaves and look.

Slides:



Advertisements
Similar presentations
AE1APS Algorithmic Problem Solving John Drake. The island of Knights and Knaves is a fictional island to test peoples ability to reason logically. There.
Advertisements

Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross By Herbert I. Gross and Richard A. Medeiros next Set 9.
Introduction to Proofs
Chapter 2 Logic Circuits.
The Island of Knights and Knaves. Knights always tell the truth.
CS344: Introduction to Artificial Intelligence (associated lab: CS386) Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture–5 and 6: Propositional Calculus.
Basic Properties of Relations
AE1APS Algorithmic Problem Solving John Drake.  Invariants – Chapter 2  River Crossing – Chapter 3  Logic Puzzles – Chapter 5 (13) ◦ Knights and Knaves.
Algebra Problems… Solutions Algebra Problems… Solutions © 2007 Herbert I. Gross Set 22 By Herbert I. Gross and Richard A. Medeiros next.
Propositional Logic. Negation Given a proposition p, negation of p is the ‘not’ of p.
1 Section 10.1 Boolean Functions. 2 Computers & Boolean Algebra Circuits in computers have inputs whose values are either 0 or 1 Mathematician George.
From Chapter 4 Formal Specification using Z David Lightfoot
Methods of Proof Lecture 4: Sep 16 (chapter 3 of the book)
Propositional Calculus Math Foundations of Computer Science.
Fall 2002CMSC Discrete Structures1 Yes, No, Maybe... Boolean Algebra.
Logic Gates Circuits to manipulate 0’s and 1’s. 0’s and 1’s used for numbers Also to make decisions within the computer. In that context, 1 corresponds.
2.5 Reasoning in Algebra and Geometry
CSci 2011 Discrete Mathematics Lecture 3 CSci 2011.
Boolean Algebra – the ‘Lingua Franca’ of the Digital World The goal of developing an automata is based on the following (loosely described) ‘ideal’: if.
Chapter 1: The Foundations: Logic and Proofs
MATH 224 – Discrete Mathematics
Methods of Proof. This Lecture Now we have learnt the basics in logic. We are going to apply the logical rules in proving mathematical theorems. Direct.
DECIDABILITY OF PRESBURGER ARITHMETIC USING FINITE AUTOMATA Presented by : Shubha Jain Reference : Paper by Alexandre Boudet and Hubert Comon.
CS 173, Lecture B August 27, 2015 Tandy Warnow. Proofs You want to prove that some statement A is true. You can try to prove it directly, or you can prove.
1 10/13/2015 MATH 224 – Discrete Mathematics Why Study Discrete Math  Determination of the efficiency of algorithms, e.g., insertion sort versus selection.
©2004 Brooks/Cole FIGURES FOR CHAPTER 2 BOOLEAN ALGEBRA Click the mouse to move to the next page. Use the ESC key to exit this chapter. This chapter in.
Methods and Solving Equations
CS1Q Computer Systems Lecture 6 Simon Gay. Lecture 6CS1Q Computer Systems - Simon Gay2 Algebraic Notation Writing AND, OR, NOT etc. is long-winded and.
Chapter 1 Logic Section 1-1 Statements Open your book to page 1 and read the section titled “To the Student” Now turn to page 3 where we will read the.
Methods of Proof Lecture 3: Sep 9. This Lecture Now we have learnt the basics in logic. We are going to apply the logical rules in proving mathematical.
Chapter 2 Section 5. Objective  Students will make a connection between reasoning in Algebra and reasoning in Geometry.
MATH 224 – Discrete Mathematics
Propositional Calculus CS 270: Mathematical Foundations of Computer Science Jeremy Johnson.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
Discrete Mathematics CS 2610 February 12, Agenda Previously Finished functions Began Boolean algebras And now Continue with Boolean algebras.
Mathematical Preliminaries
Lecture 4 Boolean Algebra. Logical Statements °A proposition that may or may not be true: Today is Monday Today is Sunday It is raining °Compound Statements.
CS1Q Computer Systems Lecture 6 Simon Gay. Lecture 6CS1Q Computer Systems - Simon Gay2 Algebraic Notation Writing AND, OR, NOT etc. is long-winded and.
© BYU 03 BA1 Page 1 ECEn 224 Boolean Algebra – Part 1.
Warm Up. Warm Up Answers Theorem and Proof A theorem is a statement or conjecture that has been shown to be true. A theorem is a statement or conjecture.
Lecture Coursework 2 AGAIN. Rectangle Game Look at proof of matchsticks A rectangular board is divided into m columns by n rows. The area of the board.
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
R. Johnsonbaugh Discrete Mathematics 5 th edition, 2001 Chapter 9 Boolean Algebras and Combinatorial Circuits.
Copyright © Curt Hill Axiomatic Approach Some needed groundwork.
Proving Statements in Geometry Eleanor Roosevelt High School Geometry Mr. Chin-Sung Lin.
Copyright © Cengage Learning. All rights reserved. CHAPTER 8 RELATIONS.
Dr. Naveed Riaz Design and Analysis of Algorithms 1 1 Formal Methods in Software Engineering Lecture # 25.
CS104:Discrete Structures Chapter 2: Proof Techniques.
Lecture Coursework 2. Rectangle Game Look at proof of matchsticks Read thru the question. A rectangular board is divided into m columns by n rows. The.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
CS 270 Lecture 1 In Class Problems. Q1: Logic Puzzle You arrive at the end of a long hallway. There are two knights guarding two doors. One knight always.
Methods of Proof Lecture 4: Sep 20 (chapter 3 of the book, except 3.5 and 3.8)
CS 173, Lecture B August 27, 2015 Tandy Warnow. Proofs You want to prove that some statement A is true. You can try to prove it directly, or you can prove.
©2010 Cengage Learning SLIDES FOR CHAPTER 3 BOOLEAN ALGEBRA (continued) Click the mouse to move to the next page. Use the ESC key to exit this chapter.
CHAPTER 2 Boolean algebra and Logic gates
Module Code MA0003NI: Computing mathematics Lecture for Week Autumn.
Lecture 1 – Formal Logic.
Niu Kun Discrete Mathematics Chapter 1 The Foundations: Logic and Proof, Sets, and Functions Niu Kun 离散数学.
CHAPTER 2 Boolean Algebra This chapter in the book includes:
SLIDES FOR CHAPTER 2 BOOLEAN ALGEBRA
FIGURES FOR CHAPTER 2 BOOLEAN ALGEBRA
CS 220: Discrete Structures and their Applications
Propositional Logic.
Formal Methods in Software Engineering
Associativity of Equivalence
Foundations of Discrete Mathematics
Introductory Concepts
Let Q be the question Let A be “the native is a knight”
BOOLEAN ALGEBRA.
Ø Let the universe set U={1,2,3,...,10}.
Presentation transcript:

Lecture 5 Knights and Knaves.

Administration Show hand in form. Show plagiarism form. Any problems with coursework? Google knight and knaves and look at picture. Do you want problem sheets this afternoon or to work on coursework.

The island of Knights and Knaves. The island of Knights and Knaves is a fictional island to test peoples’ ability to reason logically. There are two types of people on the island. Knights who always tell the truth Knaves who always lie. Logic puzzles are about deducing facts about the island, from statements made by the people on the island. But of course, you do not know whether the statement was made by a knight or a knave. I am a knight, I am a knave!!!!!

Some examples What happens if you ask a person if they are a knight or a knave? There may be gold on the island. What question could you ask to establish this? A native says “there is gold on this island, is the same as, I am a knight”. What question would you ask a pair of natives to discover if the other one is a knight? A tourist comes to a fork in a road, one way leads to a restaurant, the other does not. What question (yes/no) would you ask a native to find out which way it is to the restaurant?

Algebra At school we learnt to manipulate expressions. The values of expressions are numbers n^2 –m^2 = (n + m)(n - m) To do this we use laws. e.g. n + 0 = n and n –n = 0 (for ANY values of n) Associatively of addition (m + n) +p = m + (n + p) I am sure you are all familiar with laws regarding addition, multiplication.

Boolean algebra Boolean expressions are either true or false. Boolean valued expressions are called propositions. “it is sunny” is an atomic Boolean expression. “it is sunny and warm” is non atomic as it can be broken down into two expressions. We are concerned with the rules for manipulating Boolean expressions.

Knights and knaves. “A” is a native on the island. And is therefore either a knight or a knave. The statement “A is a knight” is either true or false. The statement “the restaurant is to the left” is either true or false. Suppose “A is a knight”, and suppose A makes statement S. The crucial observation is that the values of these two propositions are the same. Then “A is a knight” = S. Draw the truth table. P65

Example If A says “the restaurant is to the left” then “A is a knight”=”the restaurant is to the left” In words, A is a knight and the restaurant is to the left, or, A is not a knight and the restaurant is not to the left

Yes No response If a native A is asked a question Q, the response will be the truth value of A=Q. The response will be “yes” if A is a knight and the answer is really yes. Or A is a knave and the answer is really no. Otherwise the response will be “no”.

Simple example p66 A is asked whether B is a knight. And B is asked whether A is a knight. A’s response is A=B B’s response is B=A Equality is symmetrical so the two responses will always be the same. Note that this does not involve case analysis of the four cases (draw truth table)

5.2.3 Boolean Equality. Equality is reflexive. x=x It is symmetric x=y is the same as y=x It is transitive x=y and y=z implies z=x Finally x=y, then f(x) = f(y) Equality is a binary relation. It is a function with a range of Boolean values true and false.

Is equality associative? Multiplication and addition are associative. Multiplication and addition are symmetric. Is equality associative? The expression (p = q) = r does not make sense if p q r are numbers, characters, sequences or objects. Only for Boolean values. It makes sense to ask if equality of Boolean values is associative.

Associatively ((p = q) = r) = (p = (q = r)) Construct a truth table. It is true if an odd number of atoms are true. (p=p)=true and p= (p=true) The 2 nd is used for elimination.

Hidden treasures. Yes/No question A native says “I am a knight equals there is gold on the island” Let A represent “the native is a knight” Let G represent “there is gold on the island” The native’s statement is A=G so we deduce

A = (A = G) {equality of Booleans is associative} (A=A)=G {(A=A) = true} True = G {Equality is symmetrical} G=true {G = (G=true)} G We conclude that there is gold on the island, but we cannot deduce if the native is a knight or a knave.

What question to ask. You are at a fork in the road, you want to know if the gold is to the left or the right. Let Q be the question to be posed. The response to the question will be A = Q Let L denote, “the gold can be found by following the left fork” The requreimet is that L is the same are the response to Q. i.e. we reqire L=(A=Q) {but as equality is associative} (L = A) = Q So the question Q posed is L=A Ie “is the value of ‘the gold can be found by following the left fork’ equal to the value of ‘you are a knight’”

Equals for Equals There are three natives A B C. C says “A and B are both the same type”. Formulate a question, that when posed to A determines if C is telling the truth. Let A be the statement A is a “knight”. Let Q be the unknown question. The response we want is C (i.e. if C is true then C is a knight). By the previous section, Q = (A=C) i.e. we replace L by C. C’s statement is A=B, so now we know C = (A=B) by equality. So Q = (A = (A=B)) which simplifies to Q = B, so the question to be posed is “is B a knight”. Show the formal working from book p 69

Equivalence and continued Equalities Do we understand x=y=z as (x=y)=z or as x=(y=z) The two reading are different, why? Do calculation on board p71 Explain subtle difference on board. We pronounce this as equivales

Examples of the Associatively of Equivalence. A beautiful example. n + m is even equivales n is even equivales m is even We refer to “is even” of a number as parity. n + m is even equivales (n is even equivales m is even) states n + m is even when the parities of m and n are the same. (n + m is even equivales n is even) equivales m is even States, the operation of adding a number n to a number m does not change the parity of m exactly when n is even. Another way to read the statement is see page 72. This single statement avoids case analysis (four in this case).

Negation 1 Two natives A B Native A says “B is a knight equals I am not a knight” If A makes a statement S we know A=S, so we get A = (B=not A) (B=not A) means B is a knight equals I am not a knight.

Negation 2 not p = p= false Read as not p = (p = false) Functions as a definition, i.e. what does not p mean, it means p is false. Read as (not p = p) = false Is useful for simplifying in expressions. Go thru algebra on p75

Simplification The law of negation, along with associative and symmetry gives us a way to simplify expressions Do e.g. on page 75. Proof not false = true

Inequivalence. P80 A says “B is different from myself”. Formulate as B not= A Or as not (B=A) This is the same as “B is a knight equals I am not a knight” Show working p80 Inequivalence not(p=q)= p = not q Show working p80