Docsity

Logical Expressions and Quantifiers: Understanding Propositional Functions and Quantifiers, Study notes of Algorithms and Programming

Toggle sidebar
bg1
1
1
Predicates and Quantifiers
By
Chuck Cusack
2
Predicate in English
• In English, a sentence has 2 parts: the subjectand the
predicate.
• The predicate is the part of the senten ce that states
something about the su bject.
• For example, in the sentence
“John Cusack was in the movie Say Anything,”
John Cusack is the subject, and was in the movie Say
Anything is the predicate.
3
Predicate in Logic
• In logic, a predicate is something that is affirmed or denied
about the argument o f a proposition.
• For example, in the propos ition
“xwas in the movie Say Anything,”
xis the argument, and was in the m ovie Say Anything is
the predicate.
• In logic, however, the argument does not always
correspond to the subject. For instance, in the prop osition
“John Cusack was in the movie x,”
xis the argument, and John Cusack w as in the movie is
the predicate. You might prefer t o word the predicate
as is a movie that John Cusack was in.
4
Propositional Functions: Prelude
• Recall that a proposition is a s tatement that is either true or
false.
• You can think of a function as a “b lack box” which takes
one or more inputs, and produces a single output.
• You may have learned that a function has a domain (the set
of possible inputs) and a range (the set of possible
outputs).
Example:
• We can define the function square which takes as input an
integer x, and outputs its square, x2.
• The domain is set of inte gers, and the range is the set of
positive integers.
5
Propositional Function
• A propositional fu nction is a function which
– Takes one or more arguments.
– Expresses a predicate involving the argument(s).
– Becomes a proposition when values are assigned to the arguments.
• The domain of a propositional function is the set of
possible values of the arguments.
•Note: The domain must be defined so that the value of the
propositional function is a proposition for every element of
the domain.
• The range of a propositional function is the set of
propositions formed b y replacing the arguments with each
of the possible values from the dom ain.
6
Propositional Function Example
•Let P(x)=“John Cu sack was in the movie x.”
• Notice that P(x) is not a proposition, since it is neither true
nor false.
• However, P(The Matrix)=“John Cusack was in the movie
The Matrix” is a proposition with truth value false.
• In fact, for any movie title x, P(x) is eith er true or false.
• Therefore, P is a p ropositional function.
• The domain of P is the set o f all movie titles.
(e.g. P(laptop) is no t a proposition.)
• The range of P is the set of all propositions of the form
“John Cusack was in the movie x,” wh ere xis a movie title.
pf3
pf4
pf5

Partial preview of the text

Download Logical Expressions and Quantifiers: Understanding Propositional Functions and Quantifiers and more Study notes Algorithms and Programming in PDF only on Docsity!

1

Predicates and Quantifiers

By

Chuck Cusack

2

Predicate in English

  • In English, a sentence has 2 parts: the subject and the predicate.
  • The predicate is the part of the sentence that states something about the subject.
  • For example, in the sentence “John Cusack was in the movie Say Anything,” John Cusack is the subject, and was in the movie Say Anything is the predicate.

3

Predicate in Logic

  • In logic, a predicate is something that is affirmed or denied about the argument of a proposition.
  • For example, in the proposition “ x was in the movie Say Anything,” x is the argument, and was in the movie Say Anything is the predicate.
  • In logic, however, the argument does not always correspond to the subject. For instance, in the proposition “John Cusack was in the movie x,” x is the argument, and John Cusack was in the movie is the predicate. You might prefer to word the predicate as is a movie that John Cusack was in.

4

Propositional Functions: Prelude

  • Recall that a proposition is a statement that is either true or false.
  • You can think of a function as a “black box” which takes one or more inputs, and produces a single output.
  • You may have learned that a function has a domain (the set of possible inputs) and a range (the set of possible outputs). Example:
  • We can define the function square which takes as input an integer x , and outputs its square, x^2.
  • The domain is set of integers, and the range is the set of positive integers.

5

Propositional Function

  • A propositional function is a function which
    • Takes one or more arguments.
    • Expresses a predicate involving the argument(s).
    • Becomes a proposition when values are assigned to the arguments.
  • The domain of a propositional function is the set of possible values of the arguments.
  • Note: The domain must be defined so that the value of the propositional function is a proposition for every element of the domain.
  • The range of a propositional function is the set of propositions formed by replacing the arguments with each of the possible values from the domain.

6

Propositional Function Example

  • Let P( x )=“John Cusack was in the movie x .”
  • Notice that P( x ) is not a proposition, since it is neither true nor false.
  • However, P( The Matrix )=“John Cusack was in the movie The Matrix ” is a proposition with truth value false.
  • In fact, for any movie title x , P( x ) is either true or false.
  • Therefore, P is a propositional function.
  • The domain of P is the set of all movie titles. (e.g. P(laptop) is not a proposition.)
  • The range of P is the set of all propositions of the form “John Cusack was in the movie x, ” where x is a movie title.

7

Universe of Discourse

  • We all know that a universe is a particular sphere of interest, activity, or experience.
  • You may know that discourse is written or spoken communication.
  • So the universe of discourse could be defined loosely as the set of all things we wish to talk about.
  • With this in mind, perhaps it is easy to see why the domain of a propositional function is also called the universe of discourse.
  • Example: What should the universe of discourse be for the propositional function P( x )=“This week the Huskers play against x ” 8

Multiple Argument Examples

  • We mentioned earlier that propositional functions can have more than one argument. Example 1:
  • Let P( x , y ) = “ x was in the movie y .”
  • P(Kevin Bacon, The Matrix ) = “Kevin Bacon was in the movie The Matrix .”
  • P(Kevin Bacon,The Matrix) is a proposition with with truth value false.
  • What is the universe of discourse for x? How about y? For x, the set of all possible actors. For y, the set of all possible movies.

9

Multiple Argument Examples

Example 2:

  • Let P( w,x,y,z ) = “ xw+y w=z w ,” where the universe of discourse for w is the set of all positive integers, and for x , y , and z is the set of all integers.
  • P(2,3,4,5) is the proposition “ 3 2 +4^2 =5 2 ,” which has truth value true.
  • For what values of w, x, y, and z, is P( w,x,y,z ) false? (Hint: Have you heard of Fermat’s Last Theorem?) Example 3:
  • Let P(x,y)=“ x was in a movie with y .”
  • What should the universe of discourse for x and y be?
  • What is the truth value of P(Kevin Bacon, Jet Li)? 10

Another Example

Example 4:

  • Let P( x )=“ x was a movie.”
  • We can write the statement “ The Matrix was a movie” as P(The Matrix).
  • We can write the statement “ The Matrix and E.T. were movies” as P( The Matrix ) ∧ P( E.T. ).
  • How should I express a statement like “All things are movies,” or “There is at least one movie,” or “Not everything is a good movie?”
  • What about with notation like “for all x , P( x ) is true,” or “not for all x , P( x ) is true,” or “for some x , P( x ) is false,” or “there is some x for which P( x ) is true.”
  • These sort of do the job, but are too cumbersome.

11

Quantifiers

  • As the last example demonstrates, there are times when we wish to know whether or not a propositional function is true for - all members of the universe of discourse, or - no member of the universe of discourse, or - any member of the universe universe of discourse.
  • This is where quantifiers come in.
  • A quantifier is an expression that indicates the scope of something, specifically in terms of quantity.
  • In logic, the two quantifiers we are concerned about are all or every, and some, an, or at least one.

12

Universal Quantification

  • From our previous definitions of universal and quantifier, hopefully you can guess that the universal quantifier expresses all or every.
  • The universal quantification of a propositional function P( x ) is the proposition “for all x in the universe of discourse, P( x ) is true”
  • We can shorten this to “for all x P( x )” or “for every x P( x ).”
  • The notation for this is ∀ x P( x ).
  • The symbol ∀ is called the universal quantifier.

19

Truth Values for

2-Variable Quantifications

The statement is true when is false when

Truth Values of 2-Variable Quantifiers

there is at least one pair x , y for which P( x,y ) is false.

P( x,y ) is true for every pair x , y.

∀ x ∀ y P( x,y ) ∀ y ∀ x P( x,y ) there is an x for which P( x,y ) is false for every y.

for every x , there is a y for which P( x,y ) is true.

∀ x ∃ y P( x,y )

for every x , there is a y for which P( x,y ) is false.

there is an x for which P( x,y ) is true for every y.

∃ x ∀ y P( x,y )

P( x,y ) is false for every pair x , y.

there is at least one pair x , y for which P( x,y ) is true.

∃ x ∃ y P( x,y ) ∃ y ∃ x P( x,y ) 20

The Unique Parent

Problem:

  • Write the English sentence “Everybody has exactly one biological mother” as a logical expression. Solution:
  • Let P( x,y )=“ x is the biological mother of y .”
  • The expression ∀ y ∃ x P( x,y ) looks correct.
  • However, this expresses the sentence “Everybody has a biological mother,” which doesn’t guarantee that somebody doesn’t have more than one.
  • We need to express that a person can have at most one.
  • The correct solution is ∀ y ∃ x ∀ z ( P( x,y ) ∧ [ ( z ≠ x ) → ¬P( z , y ) ] )

21

Mathematical Laws

Problems:

  1. What does the logical expression ∀ x ∀ y ( x + y = y + x ) mean, where the universe of discourse for x and y is the set of real numbers? What is its truth value?
  2. What does the logical expression ∀ x ∃ y ( x * y = 1) mean, where the universe of discourse for x and y is the set of rational numbers? What is its truth value? Solutions:
  3. This is simply the commutative law of addition for real numbers, which is true.
  4. This is the multiplicative inverse law for rational numbers, which is true. 22

More Mathematical Laws?

Problems:

  1. What does the logical expression ∀ x ∀ y ( x - y = y - x ) mean, where the universe of discourse for x and y is the set of real numbers? What is its truth value?
  2. What does the logical expression ∀ x ∃ y ( x * y = 1) mean, where the universe of discourse for x and y is the set of integers? What is its truth value? Solutions:
  3. This would be the commutative law of subtraction for real numbers, but it doesn’t exist, since it is false.
  4. This would be the multiplicative inverse law for integers, but there is no such law, since it is false.

23

A Special Number

Problem:

  • Express the statement “there is a number x such that when it is added to any number, the result is that number, and if it is multiplied by any number, the result is x ” as a logical expression. Solution:
  • Let P(x,y) = “ x + y = y ,” and Q( x , y ) = “ x * y = x .”
  • Then the solution is ∃ x ∀ y ( P( x,y ) ∧ Q( x,y ) ) Which we can also write as ∃ x ∀ y ( ( x + y = y ) ∧ ( x ***** y = x ) )

24

And the Number is …

Problem:

  • What is the truth value of ∃ x ∀ y ( ( x + y = y ) ∧ ( x ***** y = x ) ) if the universe of discourse for x and y is the set of integers? Real numbers? Rational numbers? Positive integers?
  • If the truth value is true, what is the value x? Solution:
  • For the set of integers, real numbers, and rational numbers, the expression is true, with x =0.
  • For the set of positive integers, the truth value is false.

25

Negations and Quantifiers I

Problem:

  • Express the statement “Not everybody can ride a bike” as a logical expression. Solution:
  • Let P( x )=“ x can ride a bike.”
  • The statement “everybody can ride a bike,” can be expressed as ∀ x P( x ).
  • We want the negation of this, which is ¬∀ x P( x ).
  • Another way to say this is “There is somebody that cannot ride a bike,” which can be expressed as ∃ x ¬ P( x ).

26

Negations and Quantifiers II

Problem:

  • Express the statement “Nobody can fly.” as a logical expression. Solution:
  • Let P( x )=“ x can fly.”
  • The statement “somebody can fly,” can be expressed as ∃ x P( x ).
  • We want the negation of this, which is ¬∃ x P( x ).
  • Another way to say this is “Everybody can not fly,” which can be expressed as ∀ x ¬ P( x ).

27

Negating Quantifiers: The Rules

  • In the last two examples, we were able to express each statement in two different ways.
  • In fact, for any propositional function, this is the case.
  • The following chart shows the rules.

Negation Equivalent Is true when Is false when

Negating Quantifiers

P(x) is true for every x.

there is an x for which P(x) is false.

¬∀ x P( x ) ∃ x ¬ P( x )

there is an x for which P(x) is true.

P(x) is false for every x.

¬∃ x P( x ) ∀ x ¬ P( x )

28

Exercises

  1. What is the truth value of ∃ x ∀ y ( x * y = y ) if the universe of discourse for x and y is the set of real numbers? What does this expression mean?
  2. Let Q( x , y ) be the statement “ x is the capital city of y .” What should the universe of discourse be for x and y? What are the truth values of ∀ x ∃ y Q( x , y ) and ∃ x ∀ y Q( x , y )?
  3. If P(x)=“x<0,” what are the truth values of P(2), P(0), and P(-1)?
  4. Express the statement “everybody in this class is a student in this university” as a logical expression.
  5. Express the statement “Either somebody has taken every class, or everybody has taken exactly one class” as a logical expression.
  6. Let A be an array of size n , and P(i)=“A[i]=0.” You need to implement the following: If(¬∀x P(x)) Initialize all elements of A to 0 Give C++ or Java code to implement this. What does this code do?

29

More Exercises

  1. Let P( x , y ) = “ x is a factor of y ,” where the universe of discourse for x is {1,2,3,…} and for y is {2,3,4,…}. Let Q( y ) = “∀ x ( P( x , y ) →[ (x = y ) ∨ ( x = 1) ] ).” When is Q( y ) true? Give an alternative way of writing Q(y).
  2. Let P( x , y ) = “ x^2 - y^2 = 0,” where the universe of discourse for x and y is the set of integers. What are the truth values of P(4,-4), P(0,3), ∀ x ∀ y P( x , y ), ∀ x ∃y P( x , y ), ∃ x ∃y P( x , y ), and ∃y∀ x P( x , y )?
  3. Rewrite the expression ¬∀x(∃y∀z P(x,y,z)∧∃z∀y P(x,y,z) ) so no negations appear to the left of a quantifier.
  4. You need to create a random number generator that inputs an integer from 1 to 1,000,000 as a random seed, and outputs a random number from 1 to 1,000. It must be possible for each number between 1 and 1,000 to be generated. Express the requirements for this function using quantifier(s) and propositional function(s).