CSE 191, Class Note 02: Predicate Logic Computer Sci & Eng Dept SUNY Buffalo

Similar documents
Predicate Logic. Example: All men are mortal. Socrates is a man. Socrates is mortal.

Propositional Logic. A proposition is a declarative sentence (a sentence that declares a fact) that is either true or false, but not both.

Predicate Logic. For example, consider the following argument:

Lecture 16 : Relations and Functions DRAFT

Predicate Logic Review

Formalization of the CRM: Initial Thoughts

Invalidity in Predicate Logic

Handout #1: Mathematical Reasoning

Rules of Inference Friday, January 18, 2013 Chittu Tripathy Lecture 05

Lecture 8: Resolution theorem-proving

Discrete Mathematics and Probability Theory Fall 2009 Satish Rao, David Tse Note 2

3. Mathematical Induction

( ) FACTORING. x In this polynomial the only variable in common to all is x.

2. The Language of First-order Logic

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University

The Syntax of Predicate Logic

1.7. Partial Fractions Rational Functions and Partial Fractions. A rational function is a quotient of two polynomials: R(x) = P (x) Q(x).

JUST THE MATHS UNIT NUMBER 1.8. ALGEBRA 8 (Polynomials) A.J.Hobson

Factoring Polynomials

1 Mathematical Models of Cost, Revenue and Profit

If an English sentence is ambiguous, it may allow for more than one adequate transcription.

Vieta s Formulas and the Identity Theorem

10.4 Traditional Subject Predicate Propositions

The last three chapters introduced three major proof techniques: direct,

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Lecture 17 : Equivalence and Order Relations DRAFT

a 1 x + a 0 =0. (3) ax 2 + bx + c =0. (4)

Chapter 1. Use the following to answer questions 1-5: In the questions below determine whether the proposition is TRUE or FALSE

Logic in Computer Science: Logic Gates

(LMCS, p. 317) V.1. First Order Logic. This is the most powerful, most expressive logic that we will examine.

Zeros of a Polynomial Function

Partial Fractions. (x 1)(x 2 + 1)

Introduction to tuple calculus Tore Risch

1 if 1 x 0 1 if 0 x 1

EQUATIONS and INEQUALITIES

Chapter 4, Arithmetic in F [x] Polynomial arithmetic and the division algorithm.

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Covariance and Correlation

Understanding Basic Calculus

ST 371 (IV): Discrete Random Variables

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

User Guide Thank you for purchasing the DX90

1.3 Polynomials and Factoring

SQL Database queries and their equivalence to predicate calculus

CSL105: Discrete Mathematical Structures. Ragesh Jaiswal, CSE, IIT Delhi

Logic is a systematic way of thinking that allows us to deduce new information

Section 6.1 Factoring Expressions

INTRODUCTORY SET THEORY

The Division Algorithm for Polynomials Handout Monday March 5, 2012

Regular Languages and Finite State Machines

Quine on truth by convention

Syntax and Semantics for Business Rules

Solutions to Math 51 First Exam January 29, 2015

1 Propositions. mcs-ftl 2010/9/8 0:40 page 5 #11. Definition. A proposition is a statement that is either true or false.

SOLVING POLYNOMIAL EQUATIONS

Type Theory & Functional Programming

The Point-Slope Form

Quotient Rings and Field Extensions

A Beginner s Guide to Modern Set Theory

Certamen 1 de Representación del Conocimiento

The Method of Partial Fractions Math 121 Calculus II Spring 2015

Temporal Logics. Computation Tree Logic

Inner Product Spaces

Computability Theory

7 Relations and Functions

AUTOMATED REASONING SLIDES 3: RESOLUTION The resolution rule Unification Refutation by resolution Factoring Clausal Form and Skolemisation

Computational Methods for Database Repair by Signed Formulae

Mathematical Induction

This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.

3.3. The Factor Theorem. Investigate Determining the Factors of a Polynomial. Reflect and Respond

WOLLONGONG COLLEGE AUSTRALIA. Diploma in Information Technology

Lecture 13 of 41. More Propositional and Predicate Logic

Jaakko Hintikka Boston University. and. Ilpo Halonen University of Helsinki INTERPOLATION AS EXPLANATION

Copy in your notebook: Add an example of each term with the symbols used in algebra 2 if there are any.

Question: What is the probability that a five-card poker hand contains a flush, that is, five cards of the same suit?

Notes on metric spaces

Chapter 9. Systems of Linear Equations

Partial Fractions. p(x) q(x)

NOTES ON LINEAR TRANSFORMATIONS

First-Order Stable Model Semantics and First-Order Loop Formulas

Factorization in Polynomial Rings

Chapter 7. Functions and onto. 7.1 Functions

Logic and Reasoning Practice Final Exam Spring Section Number

(2)Russell. (1) The professor was drunk.

DEDUCTIVE & INDUCTIVE REASONING

Verification of Computing Policies and Other Hard Problems

SMT 2014 Algebra Test Solutions February 15, 2014

! " # The Logic of Descriptions. Logics for Data and Knowledge Representation. Terminology. Overview. Three Basic Features. Some History on DLs

Geometric Transformations

Lecture 7: Continuous Random Variables

x 2 + y 2 = 1 y 1 = x 2 + 2x y = x 2 + 2x + 1

Solving Quadratic Equations

Polynomials and Factoring

Basic Proof Techniques

Variables in Mathematics Education

CS510 Software Engineering

Application. Outline. 3-1 Polynomial Functions 3-2 Finding Rational Zeros of. Polynomial. 3-3 Approximating Real Zeros of.

CMPSCI611: Approximating MAX-CUT Lecture 20

it is easy to see that α = a

Mathematical Induction. Lecture 10-11

Transcription:

Predicate Logic CSE 191, Class Note 02: Predicate Logic Computer Sci & Eng Dept SUNY Buffalo c Xin He (University at Buffalo) CSE 191 Discrete Structures 1 / 22 From Proposition to Predicate 3 + 2 = 5 is a proposition. But is X + 2 = 5 a proposition? Because it has a variable X in it, we cannot say it is T or F. So, it is not a proposition. It is called a predicate. Definition A predicate is a function. It takes some variable(s) as arguments; it returns either True or False (but not both) for each combination of the argument values. In contrast, a proposition is not a function. It does not have any variable as argument. It is either True or False (but not both). The variables are always associated with a universe (or domain) of discourse, which tells us what combinations of the argument values are allowed. c Xin He (University at Buffalo) CSE 191 Discrete Structures 3 / 22

Predicate vs. Proposition Suppose P(x) is a predicate, where the universe of discourse for x is {1, 2, 3}. Then P(x) is not a proposition, but P(1) is a proposition. In general, a predicate is not a proposition. But when you assign values to all its argument variables, you get a proposition. P(x, y) : x + 2 = y is a predicate. It has two variables x and y; Universe of Discourse: x is in {1, 2, 3}; y is in {4, 5, 6}. P(1, 4) : P(2, 4) : 1 + 2 = 4 is a proposition (it is F); 2 + 2 = 4 is a proposition (it is T); P(2, 3): meaningless (in this example), because 3 is not in the specified universe of discourse for y. c Xin He (University at Buffalo) CSE 191 Discrete Structures 4 / 22 Example Example Suppose Q(x, y) : integer pairs. x + y > 4, where the universe of discourse is all Which of the following are predicates? Which are propositions? Q(1, 2) Q(1000, 2) Q(x, 2) Q(1000, y) Q(x, y) c Xin He (University at Buffalo) CSE 191 Discrete Structures 5 / 22

Universal quantification Universal quantification is another way of converting a predicate into a proposition. Definition Suppose P(x) is a predicate on some universe of discourse. The universal quantification of P(x) is the proposition: P(x) is true for all x in the universe of discourse. We write xp(x), and say for all x, P(x). xp(x) is TRUE if P(x) is true for every single x. xp(x) is FALSE if there is an x for which P(x) is false. c Xin He (University at Buffalo) CSE 191 Discrete Structures 6 / 22 Universal quantification example P(x) : x + 2 = 5, universe of discourse: {1, 2, 3}. x P(x) means: for all x in {1, 2, 3}, x + 2 = 5. In other words, it means: 1+2=5, 2+2=5, and 3+2=5, which is false. So it is a proposition. More example: A(x) : x = 1 B(x) : x > 2 C(x) : x < 2 Universe of discourse is {1, 2, 3}. True or False? a) x (C(x) A(x)) b) x (C(x) B(x)) c Xin He (University at Buffalo) CSE 191 Discrete Structures 7 / 22

Existential quantification Existential quantification is yet another way of converting a predicate into a proposition. Definition Suppose P(x) is a predicate on some universe of discourse. The existential quantification of P(x) is the proposition: P(x) is true for some x in the universe of discourse. We write x P(x), and say there exists x, P(x). x P(x) is TRUE if P(x) is true for any x. x P(x) is FALSE if for every x, P(x) is false. c Xin He (University at Buffalo) CSE 191 Discrete Structures 8 / 22 Existential quantification example P(x) : x + 2 = 5, universe of discourse: {1, 2, 3}. x P(x) means: for some x in {1, 2, 3}, x + 2 = 5. In other words, it means: 1 + 2 = 5, or 2 + 2 = 5, or 3 + 2 = 5 which is true. So it is a proposition. More examples on existential quantifier: A(x) : x = 1, B(x) : x > 5, C(x) : x < 5. Universe of discourse is {1, 2, 3}. True or False? a) x (C(x) A(x)) b) x B(x) c Xin He (University at Buffalo) CSE 191 Discrete Structures 9 / 22

More examples B(x): x is a CSE 191 student. C(x): x has a good GPA. All CSE 191 students have good GPA: x (B(x) C(x)) No CSE 191 student lives in Amherst: x (B(x) A(x)) CSE 191 students who do not live in Amherst major in computer science: x (B(x) A(x) D(x)) c Xin He (University at Buffalo) CSE 191 Discrete Structures 10 / 22 Quantifier negation Consider the following two propositions: Not every UB student majors in computer science: x D(x). There is UB student who does not major in computer science: x D(x). Do these two statements have the same meaning? YES. Consider the following two propositions: There is no UB student living in Amherst: x A(x). Every UB student lives in a town other than Amherst: x A(x). Do these two statements have the same meaning? YES. c Xin He (University at Buffalo) CSE 191 Discrete Structures 11 / 22

Quantifier negation Quantifier negation: In general we have: x P(x) x P(x) x P(x) x P(x) Where means logical equivalence as we have seen. Rule: to negate a quantifier: move the negation to the inside; and switch to, to. c Xin He (University at Buffalo) CSE 191 Discrete Structures 12 / 22 Nested Quantifier Sometimes we have more complicated logical formulas that require nested quantifiers. Nested means one quantifier s scope contains another quantifier. x yp(x, y) = T if P(x, y) = T for all x and y. x yp(x, y) = T if for any x there exists y such that P(x, y) = T. x yp(x, y) = T if there exists x such that P(x, y) = T for all y. x yp(x, y) = T if these exists x and there exists y such that P(x, y) = T. c Xin He (University at Buffalo) CSE 191 Discrete Structures 13 / 22

Examples for translating logic formulas to sentences Suppose P(x, y) means: x (the first variable in P(. ) loves y (the second variable in (P(, ) ), where the domain of x is the students in this class and the domain of y is the courses offered by UB CSE. Note: The variable is defined by its position in P(, ). We might use different names for them. So when we write P(y, w), we are saying y loves w. P(Alice, CSE191): Alice loves CSE191. y P(Alice, y): Alice loves a UB CSE course. x (P(x, CSE191) P(x, CSE250)): A student in this class loves both CSE 191 and CSE 250. x y z ((x y) (P(x, z) P(y, z))): There are two different students x and y in this class such that if x loves a UB CSE course, then y loves it as well. c Xin He (University at Buffalo) CSE 191 Discrete Structures 14 / 22 Example for translating sentences to logic formulas Now we consider translations in the other direction. Suppose P(x, y) means: x loves y, where the domain of x is the students in this class and the domain of y is the courses offered by UB CSE. Every UB CSE course is loved by some student in this class: y x P(x, y). No student in this class loves both CSE 191 and CSE 250: x (P(x, CSE191) P(x, CSE250)). c Xin He (University at Buffalo) CSE 191 Discrete Structures 15 / 22

Nested quantifier: examples C(x, y): x and y are friends. There is a computer science major who has a friend living in Amherst: x (D(x) y (A(y) C(x, y))) B(x): x is a CSE 191 student. C(x, y): x and y are friends. Either there is a computer science major who has a friend living in Amherst, or all CSE 191 students major in computer science: x (D(x) y (A(y) C(x, y))) x (B(x) D(x)) c Xin He (University at Buffalo) CSE 191 Discrete Structures 16 / 22 Compare examples B(x): x is a CSE 191 student. C(x, y): x and y are friends. Consider the following two statements: x y(c(x, y) B(y)): All UB students have friends taking CSE191. y x (C(x, y) B(y)): There is a UB student who is the friend of all UB students and takes CSE 191. Do they mean the same thing? NO. c Xin He (University at Buffalo) CSE 191 Discrete Structures 17 / 22

Order Matters Difference in orders of quantifiers may lead to difference in truth values. Let the universe of discourse be pairs of real numbers. x y (y > x) True But y x (y > x) False In general: x yp(x, y) = T iff y xp(x, y) = T. x yp(x, y) = T iff y xp(x, y) = T. If x yp(x, y) = T, then y xp(x, y) = T. If y xp(x, y) = T, x yp(x, y) might be F. c Xin He (University at Buffalo) CSE 191 Discrete Structures 18 / 22 Compare examples B(x): x is a CSE 191 student. C(x, y): x and y are friends. x D(x) x y (A(y) C(x, y)): There is a computer science major and there is a UB student who has a friend living in Amherst. Compared with: x (D(x) y (A(y) C(x, y))): There is a computer science major who has a friend living in Amherst. The meaning of the two statements are different. This is because the scopes of the variable x in the two formula are different. c Xin He (University at Buffalo) CSE 191 Discrete Structures 19 / 22

Scope matters In general, difference in scopes of quantifiers can lead to difference in truth values. x (P(x) P(x)) True But the truth value of x P(x) P(x) depends on the truth value of free variable x. (The second x is not bounded by any quantifier.) So this formula is not even a proposition! c Xin He (University at Buffalo) CSE 191 Discrete Structures 20 / 22 Nested quantifier: more examples B(x): x is a CSE 191 student. C(x): x has a good GPA. If all computer science majors have friends taking CSE191, then there are a pair of friends both taking CSE191. x (D(x) y (B(y) C(x, y))) x y (B(x) B(y) C(x, y)) c Xin He (University at Buffalo) CSE 191 Discrete Structures 21 / 22

Rules for quantifier scope We have the following important rules: x (P(x) Q(y)) x P(x) Q(y) x (P(x) Q(y)) x P(x) Q(y) x (P(x) Q(y)) x P(x) Q(y) x (P(x) Q(y)) x P(x) Q(y) In general, as long as a subformula does not contain a quantifier s bound variable, you can arbitrarily put it into the scope of that quantifier, or take it out of the scope of that quantifier. c Xin He (University at Buffalo) CSE 191 Discrete Structures 22 / 22