module le 5 5 p predic icate l logic ic
play

Module le 5 5: P Predic icate L Logic ic Pre-class quiz #6 is - PowerPoint PPT Presentation

2/5/17 Admin Ad Midterm 1: read the Piazza post on the two-stage exam. Assignment #2 is due Thursday Feb 2 at 4pm. Module le 5 5: P Predic icate L Logic ic Pre-class quiz #6 is due Thursday Feb 2 at 7pm. Assigned reading


  1. 2/5/17 Admin Ad • Midterm 1: read the Piazza post on the two-stage exam. • Assignment #2 is due Thursday Feb 2 at 4pm. Module le 5 5: P Predic icate L Logic ic • Pre-class quiz #6 is due Thursday Feb 2 at 7pm. • Assigned reading for the quiz: • Epp, 4th edition: 3.2, 3.4 • Epp, 3rd edition: 2.2, 2.4 1 2 Le Learni ning ng goals: pr pre-cl class CPSC CP C 121 121 - th the BI BIG que questions ns • By the start of class, you should be able to • How can we convince ourselves that an algorithm • Evaluate the truth of predicates applied to particular does what it's supposed to do? values. • We need to prove that it works. • Show a predicate logic statement is true by • We have done a few proofs in the last week or so. enumerating examples, i.e. one (all) in the domain for an existential (universal) quantifier. • Many statements (that we need to prove) involve • Show a predicate logic statement is false by quantifiers. enumerating counterexamples, i.e. all (one) in the • How do we determine whether or not one domain for an existential (universal) quantifier. algorithm is better than another one? • Translate between statements in formal predicate logic notation and equivalent statements in closely • We can finally answer that question! matching informal language , i.e., informal statements with clear and explicitly stated quantifiers. 3 4 1 1

  2. 2/5/17 Le Learni ning ng goals: in in-cl class Module 5 outline Mo • By the end of this module, you should be able to: • Predicates vs Propositions • Build statements about the relationships between • Examples properties of various objects using predicate logic. • More examples: sorted lists These may be • Algorithm efficiency revisited. • real-world like “every candidate got votes from at least two people in every province” or • Additional examples to consider. • computing related like “on the ith repetition of this algorithm, the variable min contains the smallest element in the list between element 0 and element i”. 5 6 Limitations Li ns of Propo positiona nal Lo Logic as a Wh What is predicate logic go good for Mo Model mo modeling? • Which of the following can it model effectively? • Relationships among real-world objects. a. Relationship among different people, e.g. Alice is • Generalizations about patterns married to Bob and Bob is married to Alice. • Infinite domains b. Defining what it means for a number to be • Generally, problems where the properties of the prime. different concepts, or parts, depend on each c. Generalizing from examples to abstract patterns other. like “everyone takes off their shoes at airport security”. d. Prop logic can model all of these effectively. e. Prop logic can not model any of these effectively. 7 9 2 2

  3. 2/5/17 Ex Exampl ples of pr predi dicate logi gic us use: Quantifier sy Qu syntax • Data structures: Every key stored in the left A quantifier in CPSC 121 is always of the form: subtree of a node N is smaller than the key stored at N. _____ _____ Î ______, _______________ • Language definition: No path via references exists $ or " variable set subexpression that can from any variable in scope to any memory mention the variable location available for garbage collection... • Algorithms: in the worst case, every comparison Together, this forms a single subexpression. sort requires at least cnlog2n comparisons to sort For example, $ x Î N , (x > 3) Ù (x + 4 < 12). n values, for some constant c > 0. 10 11 Qu Quantifiers syntax An Announcements • Assignment 1 being handed back in tutorials You cannot treat any part of this (like $ x Î Z or " x) • Assignment 2 and pre-class quiz due tomorrow. as a subexpression. It just isn’t. • Midterm 1 cutoff: • Roughly by the end of today’s lecture (Wednesday) So, no saying: ( $ x Î Z) Ù p. • Predicate logic will be on it but only lightly tested. • Major topics: • Logical equivalence proofs • Tautologies, contradictions, and contingencies • Circuit design • Number representation • Propositional logic proofs • Translating between predicate logic and English • A little bit of set and function theory 13 12 3 3

  4. 2/5/17 Qu Quantifier scope Quantifier scope Qu A quantifier applies to everything to its right, until A quantifier applies to everything to its right, until a closing parenthesis stops it. a closing parenthesis stops it. )∧ 𝑄 𝑦 ∀𝑦 ∈ 𝐸, (∃𝑧 ∈ 𝐹, 𝑅 𝑦, 𝑧 → ∀𝑨 ∈ 𝐺, 𝑆 𝑧, 𝑨 ฀ ฀ ∀𝑦 ∈ 𝐸 applies to the entire expression. ฀ 14 15 Quantifier scope Qu Quantifier scope Qu A quantifier applies to everything to its right, until A quantifier applies to everything to its right, until a closing parenthesis stops it. a closing parenthesis stops it. )∧ 𝑄 𝑦 )∧ 𝑄 𝑦 ∀𝑦 ∈ 𝐸, (∃𝑧 ∈ 𝐹, 𝑅 𝑦, 𝑧 → ∀𝑨 ∈ 𝐺, 𝑆 𝑧, 𝑨 ∀𝑦 ∈ 𝐸, (∃𝑧 ∈ 𝐹, 𝑅 𝑦, 𝑧 → ∀𝑨 ∈ 𝐺, 𝑆 𝑧, 𝑨 ฀ ฀ ฀ ฀ ∀𝑨 ∈ 𝐺 applies to this subexpression. ∃𝑧 ∈ 𝐹 applies to this subexpression. ฀ ฀ 16 17 4 4

  5. 2/5/17 Qu Quantifier scope Negation Ne n sc scope Which of the following placements of Which of the following placements of parentheses yields the same meaning as: parentheses yields the same meaning as: ~ ∃ x ∈ Z + , ∀ y ∈ Z + , x < y ∧ Even(y) ? ∀ x ∈ Z, ∃ y ∈ Z, x < y ∧ Even(y) ? a.(~( ∃ x)) ∈ Z + , ∀ y ∈ Z + , x < y ∧ Even(y) a.( ∀ )x ∈ Z, ∃ y ∈ Z, x < y ∧ Even(y) b.(~( ∃ x ∈ Z + )), ∀ y ∈ Z + , x < y ∧ Even(y) b.( ∀ x) ∈ Z, ∃ y ∈ Z, x < y ∧ Even(y) c.(~( ∃ x ∈ Z + , ∀ y ∈ Z + , x < y)) ∧ Even(y) c.( ∀ x ∈ Z), ∃ y ∈ Z, x < y ∧ Even(y) d.(~( ∃ x ∈ Z + , ∀ y ∈ Z + , x < y ∧ Even(y))) d.( ∀ x ∈ Z, ∃ y ∈ Z, x < y) ∧ Even(y) e.None of the above. e.( ∀ x ∈ Z, ∃ y ∈ Z, x < y ∧ Even(y)) 18 20 Wh What is a predicate? What is a predicate? Wh • A logical expression with ” unbound variables ” • PerfectSquare(y): ∃𝑦 ∈ 𝑎, 𝑦 ∗ 𝑦 = 𝑧 • We cannot determine the truth value of a predicate until we know the truth values of the • PerfectSquare(y): unknown truth value unbound variables. • PerfectSquare(10): false • ∀𝑧 ∈ 𝑎, 𝑄𝑓𝑠𝑔𝑓𝑑𝑢𝑇𝑟𝑣𝑏𝑠𝑓(𝑧) : false • Example: PerfectSquare(y): ∃𝑦 ∈ 𝑎, 𝑦 ∗ 𝑦 = 𝑧 • It’s like a function --- a mapping from the truth values of its unbound variables to the truth values of the predicate. 22 23 5 5

  6. 2/5/17 Wh Which variables ar are unbound? Wh What is a predicate? ∀ i ∈ Z + , (i ≥ n) ↔ ~ ∃ v ∈ Z + , HasValue(l, i, v) • Does every predicate have quantifier(s)? a.i and v a. Yes. b. No. b.l and n c. I don’t know c.n and v d.i and n • Examples: e.None of these are correct. 1. PerfectSquare(y): ∃𝑦 ∈ 𝑎, 𝑦 ∗ 𝑦 = 𝑧 2. IsSquare(x,y): 𝑦 ∗ 𝑦 = 𝑧 24 26 In contrast, what is a proposition? In In In contrast, what is a proposition? • A logical expression that is either true or false • Can a proposition have unbound variables? a. Yes. • Given a proposition, we can always evaluate its b. No. truth value. c. I don’t know. 27 28 6 6

  7. 2/5/17 Dif ifference be between n a pr propo position an and In In contrast, what is a proposition? a pr a predi dicate • Can a proposition have quantifiers? a. A predicate may contain one or more quantifiers, but a proposition never does. a. Yes. b. No. b. A proposition's name is a lowercase letter, c. I don’t know. whereas a predicate's name is an uppercase letter. • Examples of propositions: c. A predicate must contain unbound variables, but a proposition does not. 1. PerfectSquare(4) (4 is a perfect square.) 2. ∀𝑧 ∈ 𝑎, 𝑄𝑓𝑠𝑔𝑓𝑑𝑢𝑇𝑟𝑣𝑏𝑠𝑓 𝑧 (Every integer is a d. They are the same thing, using different names. perfect square.) e. None of the above. 29 30 Qu Quick Review (?) of Sets Wh What is a Set? A set is a collection of elements: • the set of students in this class A set is an unordered collection of objects. • the set of lowercase letters in English • the set of natural numbers (N) The objects in a set are called members. • the set of all left-handed students in this class ( a Î S indicates a is a member of S ; a Ï S indicates a is not a member of S ) An element is either in the set ( x Î S ) or not ( x Ï S ). A set contains its members. 32 33 7 7

  8. 2/5/17 De Descri ribi bing ng Sets (1/4) De Descri ribi bing ng Sets (2/4) Some sets… Some sets… A = {1, 3, 9} A = {1, 5, 25, 125, …} B = {1, 3, 9, 27, snow} B = {…, -2, -1, 0, 1, 2, …} C = {1, 1, 3, 3, 9, 9} (the same as A!) C = {1, 2, 3, …, 98, 99, 100} D = {A, B} D = { {1, 3, 9}, {1, 3, 9, 27, (The set of powers of 5, the set of integers, and the snow} } set of integers between 1 and 100.) E = { } (the empty set, with nothing in it) “…” is an ellipsis 34 35 Tr Translating between English and Mo Module 5 outline predi pr dicate logi gic • Predicates vs Propositions • All lions are fierce. • Examples • Some lion(s) do not drink coffee. • More examples: sorted lists • Algorithm efficiency revisited. • L: the set of all lions. (c) animal.discovery.com • Additional examples to consider. • F(x): x is fierce. • C(x): x drinks coffee. 36 37 8 8

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend