Quick Review (?) of Sets A set is a collection of elements: – the set of students in this class CPSC 121: Models of Computation – the set of lowercase letters in English 2018S – the set of natural numbers ( N ) – the set of all left‐handed students in this class Describing the World with Predicate Logic An element is either in the set ( x S ) or not Meghan Allen based on notes by Steve Wolfman, Patrice Belleville and others ( x S ). 1 2 What is a Set? Describing Sets (1/4) Some sets… A = {1, 3, 9} A set is an unordered collection of objects. B = {1, 3, 9, 27, snow} C = {1, 1, 3, 3, 9, 9} (the same as A!) The objects in a set are called members. D = {A, B} ( a S indicates a is a member of S ; a S indicates a is not a member of S ) D = { {1, 3, 9}, {1, 3, 9, 27, snow} } E = { } (the empty set, with nothing in it) A set contains its members. 3 4 1
Describing Sets (2/4) Describing Sets (3/4) Some sets… Some sets, using set builder notation: A = {x N | y N , x = 5 y } A = {1, 5, 25, 125, …} B = {2 i - 1 | i is a prime} B = {…, -2, -1, 0, 1, 2, …} C = {n Z | 0 < n 100} C = {1, 2, 3, …, 98, 99, 100} To read, start with “the set of all”. Read “ | ” as “such that”. (The set of powers of 5, the set of integers, and the set of integers between 1 and 100.) A : “ the set of all natural numbers x such that x is a power of 5 ” B : “ the set of all numbers of the form 2 i -1 such that i is a prime” C : “ the set of all integers n such that 0 < n 100 ” “…” is an ellipsis 5 6 Describing Sets (4/4) Outline Graphical depiction of sets: Venn diagrams. • Prereqs, Learning Goals, and Quiz Notes Draw the set of all five‐letter things. • Prelude: Scope and Predicate Definition All red things? • Problems and Discussion – Lists U is the U Texas universal – Sorted Lists snows seven set of – Comparing Algorithms everything happiness • Next Lecture Notes books fire truck heart 7 8 2
Learning Goals: Pre‐Class Learning Goals: In‐Class By the start of class, you should be able to: By the end of this unit, you should be able to: – Evaluate the truth of predicates applied to particular – Build statements about the relationships between values. properties of various objects—which may be real‐ – Show predicate logic statements are true by world like “every candidate got votes from at least enumerating examples (i.e., all examples in the two people in every province” or computing domain for a universal or one for an existential). related like “on the i th repetition of this algorithm, – Show predicate logic statements are false by enumerating counterexamples (i.e., one the variable min contains the smallest element in counterexample for universals or all in the domain for the list between element 0 and element i ”)—using existentials). predicate logic. – Translate between statements in formal predicate logic notation and equivalent statements in closely matching informal language (i.e., informal statements with clear and explicitly stated quantifiers). 9 10 Where We Are in Quiz 5 Notes The Big Stories If x and y are drawn from the 8‐bit signed ints, x Theory Hardware = 127, and y = 1, what is x+y? How do we model How do we build devices to computational systems? compute? a. ‐128 b. ‐127 Now : Finally getting a tool that Now : Still taking a bit of a we can use to model the vacation in lecture! c. 0 complex systems d. 128 we really want to reason about! e. None of these. Is “for all positive 8-bit signed x and y, x + y is positive” true? 11 12 3
Quiz 5 Notes Quiz 5 Notes Is Prime(10) Odd(2) true? How would we say: “People who are afraid of ladders are also afraid of shadows?” We are making a universal statement, but only Prime(10) means “10 is prime”, which is false. about people who match a particular quality: Odd(2) means “2 is odd”, which is false. “For any person, if they’re afraid of ladders, then they’re also afraid of shadows.” Is F F true or false? What is it now? 13 14 Limitations of Propositional Logic Outline as a Model • Prereqs, Learning Goals, and Quiz Notes Which of the following can propositional logic model effectively? • Prelude: Motivation, Scope & Defining Predicates a. Relationships among factory production lines like • Problems and Discussion “wheel assembly and frame welding both connect to the undercarriage line”. – Lists b. Defining what it means for a number to be prime. – Sorted Lists c. Generalizing from examples to abstract patterns like – Comparing Algorithms “everyone takes off their shoes at airport security”. • Next Lecture Notes d. Prop logic can model all of these effectively. e. Prop logic cannot model any of these effectively. 15 16 4
But... Would You Ever Really What Does Predicate Logic Model? Use Predicate Logic? • Data Structures Example: “...every key is less than • Relationships among real‐world objects or equal to all of its children’s keys...” • Generalizations about patterns • AI example: “...let h' be a ‘heuristic’ function • Infinite (or even just big ) domains evaluating game states and h be the true value of the state. For all nodes n, h'(n) h(n)...” • Java example: “...there is no path via references from any variable in scope to any memory location available for garbage collection...” • Economics/elections example: “...for any distinct pair of candidates c 1 and c 2 , if all voters prefer c 1 Problems where the properties of different concepts, to c 2 , then society must rank c 1 above c 2 ...” ideas, parts, or entities depend on each other. 17 18 Quantifier Syntax Quantifier Syntax You cannot treat any part of this (like x Z or x) as a A quantifier in CPSC 121 is always of the form: subexpression. It just isn’t. _____ _____ ______, _______________ So, no saying: ( x Z) p. or variable set subexpression that can mention the variable Together, this forms a single subexpression. For example, x N , (x > 3) (x + 4 < 12). 19 20 5
Quantifier Scope Quantifier Scope A quantifier applies to everything to its right A quantifier applies to everything to its right until a closing parenthesis stops it. until a closing parenthesis stops it. x D, ( y E, Q(x,y) z F, R(y,z)) P(x). one subexpression (all under the universal) 21 22 Quantifier Scope Quantifier Scope A quantifier applies to everything to its right A quantifier applies to everything to its right until a closing parenthesis stops it. until a closing parenthesis stops it. x D, ( y E, Q(x,y) z F, R(y,z)) P(x). x D, ( y E, Q(x,y) z F, R(y,z)) P(x). a smaller subexpression another smaller subexpression (all under the existential) 23 24 6
A Bit of Syntax: Quantifier Scope Quantifier Scope A quantifier applies to everything to its right Which of the following placements of until a closing parenthesis stops it. parentheses yields the same meaning as: x Z, y Z, x < y Even(y). a. ( )x Z, y Z, x < y Even(y). x D, ( y E, Q(x,y) z F, R(y,z)) P(x). b. ( x) Z, y Z, x < y Even(y). another smaller subexpression c. ( x Z), y Z, x < y Even(y). d. ( x Z, y Z, x < y) Even(y). e. ( x Z, y Z, x < y Even(y)). Reminder: Z is the set of integers. 25 26 Aside: Where Can You “Cut” a Aside: Where Can You “Cut” a Predicate Propositional Logic Statement? Logic Statement? This doesn’t make sense: (x w) ( y). This doesn’t make sense: x Z Tasty(y). Why not? Why not? Every use of looks just like every other use. Every use of looks just like every other use. They all look like p q. They all look like P(x, y, …) Q(x, y, …). The left side must make sense as an equivalent to p: The RIGHT side must make sense as an equivalent to Q( … ). p x w here. Q(y) Tasty(y) here. The right side must make sense as an equivalent to q. The left side must make sense as an equivalent to P( … ): Does q y make sense? Does P(x) x Z make sense? 27 28 7
Recommend
More recommend