1 / 43

The Foundations: Logic and Proof

The Foundations: Logic and Proof. CS104. 1.3 Propositional Equivalences. Introduction Logical Equivalences. 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.

Download Presentation

The Foundations: Logic and Proof

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Foundations: Logic and Proof CS104

  2. 1.3 Propositional Equivalences Introduction Logical Equivalences

  3. 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.

  4. 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. • Example: • Show that ¬(p ν q) and p  q are logically equivalent. De Morgan’s Laws

  5. 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)

  6. Logic Equivalence

  7. Logic Equivalence

  8. 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.

  9. 1.4 Predicates and Quantifiers Introduction Predicates Quantifiers Universal quantifier Quantifier with restricted domains Logical equivalences involving quantifiers Negating quantified expressions Translating from English into logical expressions

  10. 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.

  11. 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.

  12. 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.

  13. 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

  14. 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

  15. Predicates Example: The following code is designed to interchange the values of two variables x and y: 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 temp := x x := y y := temp

  16. 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: • 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 element under consideration for which the predicate is true.

  17. 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).

  18. 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).

  19. Universal Quantifiers

  20. 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.

  21. 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.

  22. Predicates and Quantifiers

  23. Predicates and Quantifiers

  24. Translating English Sentences

  25. 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: • Determine the quantifier used in the sentence • Determine the variable in the sentence • Determine the domain of this variable • Determine the predicate • Write complete sentence

  26. Translating English into Logical Expression

  27. Translating English into Logical Expression

  28. 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).

  29. 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).

  30. 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.

  31. 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.

  32. 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) .

  33. Negation Quantified Expression De Morgan’s laws for quantifiers Example: Show that x(P(x)Q(x)) and x(P(x)  Q(x)) are logically equivalent.

  34. 1.5 Nested Quantifiers Introduction Order of quantifiers Translating mathematical statements into statements involving nested quantifiers Translating from nested quantifiers into English

  35. Nested Quantifiers • Two quantifiers are said to be nested if one is withinthe scope of the other, such as x y (x + y = 0) • Note that xy (x + y = 0) is same as x Q(x), where Q(x) is yP(x, y), where P(x, y) is x + y = 0. • 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.

  36. Nested Quantifiers • Example: • Assume that the domain for the variables x and y consists of all real numbers. • The statement : xy (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 : xyz (x + (y + z) = (x + y) + z) is associative lawfor addition of real numbers.

  37. 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 xyP(x, y) and yxP(x, y), where the domain for all variables consists of all real numbers? • The quantification xyP(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 xyP(x, y) is also true. Also, yxP(x, y) is the proposition “For all real numbers y, for all real numbers x, x + y = y + x” = xyP(x, y), so it is true.

  38. 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 yxQ(x, y) and xyQ(x, y), where the domain for all variables consists of all real numbers? • yxQ(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 yxQ(x, y) is false. • xyQ(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, xyQ(x, y) is true.

  39. Nested Quantifiers The following table summarizes the meanings of the different possible quantifications involving two variables:

  40. Nested Quantifiers Example: Let Q(x, y, z) be the statement “x + y = z”. What are the truth values of the quantifications xyzQ(x, y, z) and zxyQ(x, y, z), where the domain for all variables consists of all real numbers? xyzQ(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 zxyQ(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

  41. 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” • Determine the quantifier used in the sentence : universal  • Determine the variable in the sentence: x and y • Determine the domain of this variable : positive integers • Determine the predicate: p(x,y) is “ x + y >0 “ • Write complete sentence : xy (x + y > 0) • Also, it can be expressed as xy((x > 0) ⌃ (y > 0) → (x + y > 0)) where the domain for both variables consists of integers.

  42. 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.

  43. Nested Quantifiers Example: Translate the statement xyz((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.

More Related