Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
The Foundations: Logic and Proof CS104 1 1.3 Propositional Equivalences •Introduction •Logical Equivalences 2 Introduction Definition1 A compound proposition that is always true, no matter what the truth values of the propositions that occurs in it, is called a tautology. A compound proposition that is always false is called a contradiction. A compound proposition that is neither a tautology or a contradiction is called a contingency. 3 p p p p p p F T T F T F T F Logic Equivalence Definition2: The compound propositions p and q are called logically equivalent if p ↔ q is a tautology. The notation p ≡ q denotes that p and q are logically equivalent. •Compound propositions that have the same truth values in all possible cases are called logically equivalent. De Morgan’s Laws Example: Show that ¬(p ν q) and p q are logically equivalent. 4 p q F T F T F F T T p q (p q) F T T T T F F F p q p q T F T F T T F F T F F F Logic Equivalence • Example3: Show that ¬p ν q and p → q are logically equivalent. Solution on the book Show that p (q r) (p q) (p r) 5 Logic Equivalence 6 Equivalence Name p Λ T p and p ν F p Identity laws p ν T T and p Λ F F Domination laws p ν p p and p Λ p p Idempotent laws ¬( ¬ p) p Double negation law p ν q q ν p and p Λ q q Λ p Commutative laws (p ν q) ν r p ν (q ν r) and (p Λ q) Λ r p Λ (q Λ r) Associative laws p (q r) (p q) (p r) p (q r) (p q) (p r) Distributive laws ¬(p ν q) ¬p Λ ¬q and ¬(p Λ q) ¬p ν ¬q De Morgan’s laws p (p q) p and p (p q) p Absorption laws p ν ¬p T and p Λ ¬p F Negation laws Logic Equivalence 7 Logic Equivalence Example6: Show that ¬(p → q ) and p Λ ¬q are logically equivalent. Solution: ¬(p → q ) ≡ ¬(¬p ν q) ≡ ¬(¬p) Λ ¬q by the second De Morgan law ≡ p Λ ¬q by the double negation law Example8: Show that (p Λ q) → (p ν q) is a tautology. Solution: To show that this statement is a tautology, we will use logical equivalences to demonstrate that it is logically equivalent to T. (p Λ q) → (p ν q) ≡ ¬(p Λ q) ν (p ν q) ≡ (¬ p ν ¬q) ν (p ν q) by the first De Morgan law ≡ (¬ p ν p) ν (¬ q ν q) by the associative and communicative law for disjunction ≡TνT ≡T Note: The above examples can also be done using truth tables. 8 1.4 Predicates and Quantifiers •Introduction •Predicates •Quantifiers •Universal quantifier •Quantifier with restricted domains •Logical equivalences involving quantifiers •Negating quantified expressions 9 •Translating from English into logical expressions Predicates and Quantifiers • Propositional logic cannot adequately express the meaning of all statements in mathematics and natural language ! e.g. we know that : “ every computer connected to the network is functioning properly “ , • Predicate Logic : is a powerful type of logic that could be used to express the meaning of wide range of statements in mathematics and CS. • Two main concepts are introduced: Predicate Quantifiers. 10 Predicates and Quantifiers • Predicate: • Statements involving variables such as : x > 3, x = y + 3 , x + y = z are neither True nor false when the value of variables are not specified. • This section discusses how proposition can be produced from such statements • The statement x>3 has two parts : the first part: subject of statement ,variable x the second part: predicate , a property that the subject of a statement can have , “ is greater than 3” • The statement could be denoted by : P(x) , propositional function ,where p is a predicate(is greater than 3), x is a variable. • Once we assign a value to variable x, P(x) becomes a proposition that could be True or False. 11 Predicates • Example: Let P(x) : x > 3 , what is the truth value of P(4) ? setting x = 4 , 4 > 3 , true Let P (x,y) : x = y + 3, what is the truth value of P(1,2) , “ involve more than one variable ! “ 1 = 2 + 3 , false • A statement of the form P(x1, x2, …., xn) is the value of the propositional function P at the n-tuple (x1, x2, …., xn) and P is called n-ary predicate • Propositional function occurs in computer programs as in the following example. 12 Predicates Example: Consider the statement if x > 0 then x := x + 1. Here P(x) = “x > 0”. If P(x) is true for the value of x, then the assignment statement x := x + 1 is executed, x is increased by 1. If P(x) is false for the value of x, then the assignment statement is not executed, x remains same 13 Predicates Usage of Predicate: • Predicate are used to establish the correctness of computer program, i.e. to show that computer programs always produce the desired output when given valid input. • Precondition: statements that describe valid input • Postcondition: condition that the output should satisfy when the program has run 14 Predicates Example: The following code is designed to interchange the values of two variables x and y: temp := x x := y y := temp The predicate for precondition: P (x ,y) where P (x , y) is x = a , y = b The predicate for postcondition: Q ( x , y) where Q ( x , y) is x = b , y = a 15 Quantifiers Quantification : • It is a way to create a proposition from a propositional function. • It expresses the extent to which a predicate is true over a range of elements. • In English, the words all, some , many, none and few are used in quantification. Types of Quantification: 1. Universal quantification: Which tells that a predicate is true for every element under consideration. 2. Existential quantification: Which tells that there is one or more 16 element under consideration for which the predicate is true. Universal Quantifiers Universal Quantifiers: • Many mathematical statements assert that a property is true for all values of a variable in a particular domain. • The universal quantification of P(x) for particular domain is the statement “P(x) is true for all values of x in the domain”. • The notation x P(x) denotes the universal quantification of P(x). Here is called universal quantifier. • The meaning of the universal quantification of P(x) changes when the domain is changed. • An element for which P(x) is false is called a counterexample of x P(x). 17 Universal Quantifiers Example: Let P(x) = “x+1 > x”. What is the truth value of the quantification x P(x), where the domain consists of all real numbers? Because P(x) is true for all real numbers x, the quantification x P(x) is true. Example: Let Q(x) = “x < 2”. What is the truth value of the quantification x Q(x), where the domain consists of all real numbers? Because Q(x) is not true for every real number x, because, for instance, Q(3) is false. That is, x=3 is a counterexample for the statement x Q(x). 18 Universal Quantifiers 19 Existential Quantifiers Existential Quantifier • Many mathematical statements assert that there is an element with a certain property. • The existential quantification of P(x) is the statement “There exists an element x in the domain such that P(x)”. • The notation x P(x) denotes the existential quantification of P(x). Here is called existential quantifier. 20 Existential Quantifiers Example: Let P(x) = “x > 3”. What is the truth value of the quantification x P(x), where the domain consists of all real numbers? Because P(x) is sometimes true - for instance, when x=4 – the existential quantification of P(x), which is x P(x), is true. Example: Let P(x) = “x = x+1”. What is the truth value of the quantification x P(x), where the domain consists of all real numbers? Because P(x) is false for every real number x, the quantification x P(x) is false. 21 Predicates and Quantifiers Statement x P(x) When True? P(x) is true for every x When False? There is an x for which P(x) is false x P(x) There is an x for which P(x) is false for every P(x) is true x Predicates and Quantifiers 23 Translating English Sentences 24 Translating English into Logical Expression • Translating from English to logical expression becomes even more complex when quantifiers are needed ! , and it could be done in four main steps: 1. Determine the quantifier used in the sentence 2. Determine the variable in the sentence 3. Determine the domain of this variable 4. Determine the predicate 5. Write complete sentence 25 Translating English into Logical Expression 26 Translating English into Logical Expression Quantifiers with Restricted Domains Quantifiers with Restricted Domains: • An abbreviated notation is used to restrict the domain of a quantifier. In this notation, a condition, a variable must satisfy, is included after the quantifier. • The restriction of a universal quantification is the same as the universal quantification of a conditional statement. For instance, x < 0(x2 > 0) is another way of expressing x (x < 0 → x2 > 0). • The restriction of an existential quantification is the same as the existential quantification of a conjunction. For instance, z>0 (z2=2) can be expressed as z (z > 0 ˄ z2 = 2). 28 Quantifiers with Restricted Domains Example: What do the statement x < 0(x2 > 0), and z > 0(z2 = 2) mean? The statement x < 0(x2 > 0) states that for every number x with x < 0, x2 > 0. That is, it states “The square of a negative real number is positive”. The statement is the same as x (x < 0 → x2 > 0). The statement z > 0(z2 = 2) states that there exist a real number z with z > 0 such that z2=2. That is, it states “There is positive square root of 2”. The statement is the same as z (z > 0 ˄z2 = 2). 29 Logical Equivalences Involving Quantifiers Precedence of Quantifiers: • The quantifiers and have higher precedence then all logical operators from propositional calculus. • For example, xP(x) v Q(x) is the disjunction of xP(x) and Q(x). In other words, it means (xP(x)) v Q(x) rather than x (P(x) v Q(x)) Logical Equivalences Involving Quantifiers: Statements involving predicate and quantifiers are logically equivalent if and only if they have the same truth value no matter which predicates are substituted into these statements and which domain of discourse is used for the variables in these propositional functions. 30 Logical Equivalences Involving Quantifiers Example: Show that x (P(x) Q(x)) and xP(x) x Q(x) are logically equivalent. Let x (P(x) Q(x)) is true => if a is in the domain, then P(a) Q(a) is true => P(a) and Q(a) are true, for all a in the domain => xP(x) and xQ(x) are true => xP(x) xQ(x) is true So, they are logically equivalent. 31 Negation Quantified Expression Example: “Every student in your class has taken a course in calculus” Domain consists of the students in your class. P(x) is the statement “x has taken a course in calculus” x P(x). Negation of the statement: “It is not the case that every student in your class has taken a course in calculus”. This equivalent to “There is a student in your class who has not taken a course in calculus”. This is simply the existential quantification x P(x) . 32 Negation Quantified Expression De Morgan’s laws for quantifiers When is Negation True? When False? x P(x) Equivalent Statement x P(x) For every x, P(x) is false There is an x for which P(x) is true x P(x) x P(x) There is an x for which P(x) is false P(x) is true for every x Negation Example: Show that x(P(x)Q(x)) and x(P(x) Q(x)) are logically equivalent. 33 1.5 Nested Quantifiers •Introduction •Order of quantifiers •Translating mathematical statements into statements involving nested quantifiers •Translating from nested quantifiers into English 34 Nested Quantifiers • Two quantifiers are said to be nested if one is within the scope of the other, such as x y (x + y = 0) o Note that xy (x + y = 0) is same as x Q(x), where Q(x) is yP(x, y), where P(x, y) is x + y = 0. o It says that for every real number x there is a real number y such that x + y = 0. This states that every real number has an additive inverse. 35 Nested Quantifiers Example: Assume that the domain for the variables x and y consists of all real numbers. • The statement : xy (x + y = y + x) says that x + y = y + x for all real numbers x and y. This is commutative law for addition of real numbers. • The statement : xyz (x + (y + z) = (x + y) + z) is associative law for addition of real numbers. Nested Quantifiers • The order of the quantifiers is important unless all the quantifiers are universal quantifiers or all are existential quantifiers. Example: Let P(x, y) be the statement “x + y = y + x”. What are the truth values of the quantifications xyP(x, y) and yxP(x, y), where the domain for all variables consists of all real numbers? The quantification xyP(x, y) is the proposition “For all real numbers x, for all real numbers y, x + y = y + x”. Since P(x, y) is true for all real numbers x and y, the proposition xyP(x, y) is also true. Also, yxP(x, y) is the proposition “For all real numbers y, for all real numbers x, x + y = y + x” = xyP(x, y), so it is true. 37 Nested Quantifiers Note: Order of nested universal quantifiers in a statement without other quantifiers can be changed without changing meaning of quantified statement. Example: Let Q(x, y) be the statement “x + y = 0”. What are the truth values of the quantifications yxQ(x, y) and xyQ(x, y), where the domain for all variables consists of all real numbers? • yxQ(x, y) = “There is a real number y such that for every real number x, x + y = 0”. Since there is no real number y such that x + y = 0, for all real numbers x, the proposition yxQ(x, y) is false. • xyQ(x, y) = “For every real number x, there is a real number y such that x + y = 0”. Given a real number x, there is a real number y, namely y = -x, such that x + y =0. So, xyQ(x, y) is true. 38 Nested Quantifiers The following table summarizes the meanings of the different possible quantifications involving two variables: Statement When True? When False? xyP(x, y) yxP(x, y) P(x, y) is true for every pair x, y. There is a pair x, y for which P(x, y) is false xyP(x, y), For every x there is a y for which P(x, y) is true There is an x such that P(x, y) is false for every y xyP(x, y) There is an x such that P(x, y) is true for every y For every x there is a y for which P(x, y) is false xyP(x, y) yxP(x, y) There is a pair x, y for which P(x, y) P(x, y) is false for every pair x, y. is true 39 Nested Quantifiers Example: Let Q(x, y, z) be the statement “x + y = z”. What are the truth values of the quantifications xyzQ(x, y, z) and zxyQ(x, y, z), where the domain for all variables consists of all real numbers? xyzQ(x, y, z) = “For all real numbers x and for all real numbers y there is a real number z such that x + y = z” is true. The order of quantification is important here. Since zxyQ(x, y, z) = “There is a real number z such that for all real numbers x and for all real numbers y, x + y = z”, is false, because there is no z that satisfies th equation x + y = z for all for all real numbers x and y 40 Nested Quantifiers Example: Translate the statement “The sum of two positive integers is always positive” into a logical expression. Let x and y be two positive integers, then we can write the statement as “For all positive integers x and y, x + y is positive” 1. Determine the quantifier used in the sentence : universal 2. Determine the variable in the sentence: x and y 3. Determine the domain of this variable : positive integers 4. Determine the predicate: p(x,y) is “ x + y >0 “ 5. Write complete sentence : xy (x + y > 0) Also, it can be expressed as xy((x > 0) ⌃ (y > 0) → (x + y > 0)) where the domain for both variables consists of integers. 41 Nested Quantifiers Example: Translate the statement “Every real number except zero has a multiplicative inverse” into a logical expression. Example: Translate the statement x(C(x) v y(C(y) ⌃ F(x, y))) into English, where C(x)=“x has a computer”, F(x, y) = “x and y are friends”, and the domain for both x and y consists of all students in your class. The statement says that for every student x in your class, x has a computer or there is a student y such that y has computer and x and y are friends. In other words, every student in your class has a computer or has a friend who has a computer. 42 Nested Quantifiers Example: Translate the statement xyz((F(x, y) ⌃ F(x, z) ⌃ (y ≠ z)) → F(y, z)) into English, where F(a, b) means a and b are friends and the domain for x, y and consists of all students in your class.