Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville.

Slides:



Advertisements
Similar presentations
CPSC 121: Models of Computation Unit 6 Rewriting Predicate Logic Statements Based on slides by Patrice Belleville and Steve Wolfman.
Advertisements

Chapter 1: The Foundations: Logic and Proofs 1.1 Propositional Logic 1.2 Propositional Equivalences 1.3 Predicates and Quantifiers 1.4 Nested Quantifiers.
Predicates and Quantifiers
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Proof Techniques (Part A) Steve Wolfman, based on notes by Patrice Belleville and others.
RMIT University; Taylor's College This is a story about four people named Everybody, Somebody, Anybody and Nobody. There was an important job to be done.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Proof Techniques Steve Wolfman, based on notes by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2009 Winter Term 1 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Propositional Logic: Conditionals and Logical Equivalence Steve Wolfman, based on notes.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville.
Discrete Mathematics Lecture 2 Alexander Bukharovich New York University.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Proof Techniques Steve Wolfman, based on notes by Patrice Belleville and others.
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Proof Techniques Steve Wolfman, based on notes by Patrice Belleville and others 1.
Snick  snack CPSC 121: Models of Computation 2010 Winter Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
First Order Logic (chapter 2 of the book) Lecture 3: Sep 14.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Proof Techniques (Part B) Steve Wolfman, based on notes by Patrice Belleville and others.
Discrete Structures Chapter 3: The Logic of Quantified Statements
Snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Proof (First Visit) Steve Wolfman, based on notes by Patrice Belleville, Meghan Allen.
CSE115/ENGR160 Discrete Mathematics 01/20/11 Ming-Hsuan Yang UC Merced 1.
Harper Langston New York University Summer 2015
First Order Logic. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about first order.
Predicates and Quantifiers
The Foundations: Logic and Proofs
MATH 224 – Discrete Mathematics
 Predicate: A sentence that contains a finite number of variables and becomes a statement when values are substituted for the variables. ◦ Domain: the.
Week 3 - Monday.  What did we talk about last time?  Predicate logic  Multiple quantifiers  Negating multiple quantifiers  Arguments with quantified.
Week 2 - Friday.  What did we talk about last time?  Predicate logic  Negation  Multiple quantifiers.
(CSC 102) Lecture 7 Discrete Structures. Previous Lectures Summary Predicates Set Notation Universal and Existential Statement Translating between formal.
Snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Rewriting Predicate Logic Statements Steve Wolfman, based on notes by Patrice Belleville.
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.
Section 1.5. Section Summary Nested Quantifiers Order of Quantifiers Translating from Nested Quantifiers into English Translating Mathematical Statements.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
2.3Logical Implication: Rules of Inference From the notion of a valid argument, we begin a formal study of what we shall mean by an argument and when such.
First Order Logic Lecture 2: Sep 9. This Lecture Last time we talked about propositional logic, a logic on simple statements. This time we will talk about.
Copyright © Cengage Learning. All rights reserved. CHAPTER 3 THE LOGIC OF QUANTIFIED STATEMENTS THE LOGIC OF QUANTIFIED STATEMENTS.
Chapter 1, Part II: Predicate Logic With Question/Answer Animations.
Lecture 1.2: Equivalences, and Predicate Logic* CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Cinda Heeren, Zeph.
Snick  snack CPSC 121: Models of Computation 2012 Summer Term 2 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville.
Discrete Mathematics. Predicates - the universal quantifier 11/28/2015 Suppose P(x) is a predicate on some universe of discourse. Ex. B(x) = “x is carrying.
(CSC 102) Lecture 8 Discrete Structures. Previous Lectures Summary Predicates Set Notation Universal and Existential Statement Translating between formal.
1 Introduction to Abstract Mathematics Chapter 2: The Logic of Quantified Statements. Predicate Calculus Instructor: Hayk Melikya 2.3.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 02: QUANTIFIERS Sections 1.3 and 1.4 Jarek Rossignac CS1050:
CS 285- Discrete Mathematics Lecture 4. Section 1.3 Predicate logic Predicate logic is an extension of propositional logic that permits concisely reasoning.
Snick  snack CPSC 121: Models of Computation 2011 Winter Term 1 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville.
First Order Logic Lecture 3: Sep 13 (chapter 2 of the book)
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
CPSC 121: Models of Computation Unit 5 Predicate Logic Based on slides by Patrice Belleville and Steve Wolfman.
1 Propositional Logic: Fundamental Elements for Computer Scientists 0. Motivation for Computer Scientists 1. Propositions and Propositional Variables 2.
Lecture 1.2: Equivalences, and Predicate Logic CS 250, Discrete Structures, Fall 2015 Nitesh Saxena Adopted from previous lectures by Cinda Heeren, Zeph.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Predicates and Quantifiers
Week 3 - Monday.  What did we talk about last time?  Predicate logic  Multiple quantifiers  Negating multiple quantifiers  Arguments with quantified.
Week 4 - Friday.  What did we talk about last time?  Floor and ceiling  Proof by contradiction.
321 Section, Week 2 Natalie Linnell. Extra Credit problem.
Section 1.5 and 1.6 Predicates and Quantifiers. Vocabulary Predicate Domain Universal Quantifier Existential Quantifier Counterexample Free variable Bound.
Mathematics for Comter I Lecture 3: Logic (2) Propositional Equivalences Predicates and Quantifiers.
Section 1.4. Propositional Functions Propositional functions become propositions (and have truth values) when their variables are each replaced by a value.
Snick  snack CPSC 121: Models of Computation 2013W2 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville and.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
CPSC 121: Models of Computation 2016W2
3. The Logic of Quantified Statements Summary
CPSC 121: Models of Computation
Chapter 1 The Foundations: Logic and Proofs
Predicates and Quantifiers
Discrete Mathematics Lecture 4 Logic of Quantified Statements
CPSC 121: Models of Computation
Copyright © Cengage Learning. All rights reserved.
CPSC 121: Models of Computation
CPSC 121: Models of Computation
Presentation transcript:

snick  snack CPSC 121: Models of Computation 2008/9 Winter Term 2 Describing the World with Predicate Logic Steve Wolfman, based on notes by Patrice Belleville and others

Quiz 5 Notes Predicate translation went great! A few other problems caused trouble... Consider all variables in this problem to be drawn from the domain of 8-bit signed ints, not mathematical integers. Is the following statement true?

Quiz 5 Notes A few other problems caused trouble... Let P(x) be the predicate statement “x is prime” and O(x) be “x is odd”. Is P(10)  O(2) true?

Quiz 5 Notes A few other problems caused trouble...

Quiz 5 Notes: Sorting My wording focused many on “corresponding”, not “sorted”! What is “corresponding”? Unchanged contents: –everything in the first list is in the second –in one if and only if it's in the other –only order (indexes) changes, not values What is sorted? –need a definition for order (alphabetical?) –each element is >= the previous and <= the next –first element higher than all other elements; second is higher than all but one;... Lastly, a notion that “sorted” should mean “more organized” somehow.

Lecture Prerequisites Review Chapter 1 and be able to solve any Chapter 1 exercise. Read Sections 2.1 and 2.3 (skipping the “Negation” sections in 2.3 on pages ) Solve problems like Exercise Set 2.1 #1-24 and Set 2.3 #1-12, part (a) of 14-19, 21-22, 30-31, part (a) of 32-38, 39, parts (a) and (b) of , and You should have completed the open-book, untimed quiz on Vista that was due before this class.

Learning Goals: Pre-Class By the start of class, you should be able to: –Evaluate the truth of predicates applied to particular values. –Show predicate logic statements are true by enumerating examples (i.e., all examples in the domain for a universal or one for an existential). –Show predicate logic statements are false by enumerating counterexamples (i.e., one counterexample for universals or all in the domain for existentials). –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).

Learning Goals: In-Class By the end of this unit, you should be able to: –Build statements about the relationships between properties of various objects—which may be real-world like “every candidate got votes from at least two people in every province” or 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”)—using predicate logic.

What Does Predicate Logic Model? Propositional logic is a good (but not perfect) model of combinational circuits. What is predicate logic good for modeling? Relationships among real-world objects Programming constraints Properties of computing systems Generally, problems where the properties of different concepts, ideas, parts, or entities depend on each other.

Problem: Lists (aka Arrays) Let Elt(a, i, v) be a predicate indicating that list a has the integer value v at index i, where indexes must be  0. Problem: write a statement that means that some arrays contain duplicate values.

Problem: Lists (aka Arrays) Let’s assume that for any given list: (1)The list has a length. (We’ll call it len here for simplicity.) (2)The list has exactly one value for every index < len. (3)The list has no values for indexes >= len. Problem: Write logical statements that express these constraints. You may need to invent a new predicate. Predicates are clumsy for expressing these common ideas. Later, we’ll use functions to do a better job.

Problem: Sorted Lists Problem: Give a definition for the predicate Sorted(a) in terms of Elt(a, i, v).

Problem: Voting Database Consider a database that tracks the votes in an election. In the database, the predicate Tally(d, c, n) means that district d reported that candidate c received n votes, where n is an integer  0. Problem: Define a predicate GotVote(c) in terms of Tally whose truth set is the set of all candidates who received at least one vote.

Problem: Voting Database Problem: Define a predicate whose truth set is the set of all candidates who won at least one district. Why work so hard on defining predicates? This is essentially how we query databases.

Problem: Voting Database Let’s assume that every candidate has exactly one vote total for every district. That is, there’s no missing and no duplicate data. Problem: Write a logical statement that describes this constraint. Predicates are clumsy for expressing this common idea. Later, we’ll use functions to do a better job.

Problem: Voting Database Let Winner(c) indicate that candidate c is the winner of the election. Problem: Write a logical statement that means that the winner of the election must have received at least one vote.

Problem: Voting Database Let D be the set of all districts and C be the set of all candidates. Problem: Determine what the following statement means, whether it is necessarily true (no matter what the actual vote tallies are), and justify your stance:  c 1  C,  d  D,  c 2  C, Winner(c 1 )  c 1  c 2   n 1  Z,  n 2  Z, Tally(d,n 1,c 1 )  Tally(d,n 2,c 2 )  n 1 >n 2

Problem: Efficiency of Algorithms (1 of 3) Let’s say each student is in a “MUG” (1st year orientation group). For each of their MUG-mates, each student has a list of all of their classes. For simplicity, we’ll assume each MUG has 13 students and each student is taking 5 classes. I want to determine how many students in my class have a MUG-mate in my class.

Problem: Efficiency of Algorithms (2 of 3) I consider the following two algorithms: –MUG-lists algorithm: For each student, ask the student for the list of their MUG-mates’ classes, and check for each class whether it is CPSC 121. If the answer is ever yes, include the student in my count. Let’s this takes one second for each class I check. –Pairwise recognition algorithm: For each student s 1 in the class, ask the student for each other student s 2 in the class whether s 2 is a MUG-mate. If the answer is ever yes, include s 1 in my count. Let’s say a student takes one second to determine whether another student is a MUG-mate.

Problem: Efficiency of Algorithms (3 of 3) Problem: How long does each of these algorithms take in terms of the number of students?

Problem: Detailed Efficiency of Algorithms Let the predicate Faster(a 1, a 2, n) mean algorithm a 1 is faster than algorithm a 2 on a problem of size n, where n is a positive integer. Problem: for which n s is Faster(MUG- list, pairwise, n) true?

Problem: General Efficiency of Algorithms Let the predicate Faster(a 1, a 2, n) mean algorithm a 1 is faster than algorithm a 2 on a problem of size n, where n is a positive integer. Problem: create a definition of GenerallyFaster(a 1, a 2 ) in terms of Faster(a 1, a 2, n) that you can live with.

Learning Goals: In-Class By the start of class, you should be able to: –Build statements about the relationships between properties of various objects—which may be real-world like “every candidate got votes from at least two people in every province” or 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”) using predicate logic.

Next Lecture Learning Goals: Pre-Class By the start of class, you should be able to: –Determine the negation of any quantified statement. –Given a quantified statement and an equivalence rule, apply the rule to create an equivalent statement (particularly the De Morgan’s and contrapositive rules). –Prove and disprove quantified statements using the “challenge” method (Epp, 3 d edition, page 99). –Apply universal instantiation, universal modus ponens, and universal modus tollens to predicate logic statements that correspond to the rules’ premises to infer statements implied by the premises.

Next Lecture Prerequisites Reread Sections 2.1 and 2.3 (including the negation part that we skipped previously). Read Sections 2.2 and 2.4. Solve problems like Exercise Set 2.1 #25-28 and ; Set 2.2 #1-25 and 27-36; Set 2.3 #13-20, , 40-42, and 45-52; and Set 2.4 #2-19, and (You needn’t learn the “diagram” technique, but it may make more sense than other explanations!) Complete the open-book, untimed quiz on Vista that’s due before the next class.

Problem: Java Collections Problem: Translate the following text from the Java API page for the Collection interface into predicate logic. [T]he specification for the contains(Object o) method says: "returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e))." contains(Object o) c ? a : b acts essentially like a multiplexer. If c is true, it evaluates to a; otherwise, it evaluates to b.

Problem: Java Collections Problem: The API goes on to say: This specification should not be construed to imply that invoking Collection.contains with a non-null argument o will cause o.equals(e) to be invoked for any element e. Explain whether and how this is consistent with your definition.

More Quantifier Examples Someone is in charge. Everyone except the person in charge reports to someone else.

More Quantifier Examples n is a prime number. Note: we use x|y as a predicate meaning x divides y (i.e., x “goes into” y with no remainder).

More Quantifier Examples n is a prime number. Let’s define a new predicate P(x) in terms of this “clause”. Then, let’s express… There’s some prime number larger than 10. There’s some prime number larger than every natural number.

Yet More Examples Eating food causes Alice to grow or shrink. F = set of all foods E(x) : Alice eats x g : Alice grows s : Alice shrinks

Yet More Examples Alice shrank when she ate some food. F = set of all foods E(x) : Alice eats x g : Alice grows s : Alice shrinks

Yet More Examples All lions are fierce. F(x) : x is a fierce creature L(x) : x is a lion C(x) : x drinks coffee Domain for all is the set of all creatures.

Yet More Examples Some lions do not drink coffee. F(x) : x is a fierce creature L(x) : x is a lion C(x) : x drinks coffee Domain for all is the set of all creatures.

Yet More Examples All fierce creatures are not lions. F(x) : x is a fierce creature L(x) : x is a lion C(x) : x drinks coffee Domain for all is the set of all creatures. Is that English sentence ambiguous?

Yet More Examples Is  x, K(x, y) a proposition? Why or why not? F(x) : x is a fierce creature L(x) : x is a lion C(x) : x drinks coffee K(x, y) : x has been in y ’s kitchen Domain for all is the set of all creatures (with kitchens?).

Yet More Examples Every creature has been in its own kitchen. Some creature has not been in its own kitchen. F(x) : x is a fierce creature L(x) : x is a lion C(x) : x drinks coffee K(x, y) : x has been in y ’s kitchen Domain for all is the set of all creatures (with kitchens?).

Yet More Examples There is a creature that has been in every creature’s kitchen. Every creature’s kitchen has had some creature in it. F(x) : x is a fierce creature L(x) : x is a lion C(x) : x drinks coffee K(x, y) : x has been in y ’s kitchen Domain for all is the set of all creatures (with kitchens?). Are these the same?

Yet More Examples Every creature has been in every other creature’s kitchen. Every creature’s kitchen has had every creature in it. F(x) : x is a fierce creature L(x) : x is a lion C(x) : x drinks coffee K(x, y) : x has been in y ’s kitchen Domain for all is the set of all creatures (with kitchens?). Are these the same? What if we removed the word “other”?