0% found this document useful (0 votes)
16 views13 pages

Discrete Class 5

The document introduces predicate logic as a more powerful form of logic than propositional logic, allowing for the expression of statements involving variables and quantifiers. It explains predicates, preconditions, and postconditions, and discusses universal and existential quantification, providing examples to illustrate these concepts. Additionally, it covers the binding of variables and the scope of quantifiers in logical expressions.

Uploaded by

tamilavatar06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views13 pages

Discrete Class 5

The document introduces predicate logic as a more powerful form of logic than propositional logic, allowing for the expression of statements involving variables and quantifiers. It explains predicates, preconditions, and postconditions, and discusses universal and existential quantification, providing examples to illustrate these concepts. Additionally, it covers the binding of variables and the scope of quantifiers in logical expressions.

Uploaded by

tamilavatar06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Discrete MAthematics

1. Logic and Proofs


Class-5
Predicates and Quantifiers

Propositional logic, studied so far, cannot adequately express the meaning of all statements in mathematics
and in natural language. For example, suppose that we know that

“Every computer connected to the university network is functioning properly.”


No rules of propositional logic allow us to conclude the truth of the statement

“MATH3 is functioning properly,”


where MATH3 is one of the computers connected to the university network.

Likewise, we cannot use the rules of propositional logic to conclude from the statement

“CS2 is under attack by an intruder,”


where CS2 is a computer on the university network, to conclude the truth of

“There is a computer on the university network that is under attack by an intruder.”

In this section we will introduce a more powerful type of logic called predicate logic.
Predicates

Statements involving variables, such as


“x > 3,” “x = y + 3,” “x + y = z,”

and
“Computer x is under attack by an intruder,”
and
“Computer x is functioning properly,”
are often found in mathematical assertions, in computer programs, and in system specifications. These statements
are neither true nor false when the values of the variables are not specified.
The statement “x is greater than 3” has two parts. The first part, the variable x, is the subject of the statement. The
second part—the predicate, “is greater than 3”—refers to a property that the subject of the statement can have.
We can denote the statement “x is greater than 3” by P(x), where P denotes the predicate “is greater than 3” and x
is the variable. The statement P(x) is also said to be the value of the propositional function P at x. Once a value has
been assigned to the variable x, the statement P(x) becomes a proposition and has a truth value.

EXAMPLE 1 Let P(x) denote the statement “x > 3.” What are the truth values of P(4) and P(2)?
Solution: We obtain the statement P(4) by setting x = 4 in the statement “x > 3.” Hence, P(4), which is the statement
“4 > 3,” is true. However, P(2), which is the statement “2 > 3,” is false.
Predicates

EXAMPLE 2 Let A(x) denote the statement “Computer x is under attack by an intruder.” Suppose that of the computers
on campus, only CS2 and MATH1 are currently under attack by intruders. What are truth values of A(CS1), A(CS2), and
A(MATH1)?

Solution: We obtain the statement A(CS1) by setting x = CS1 in the statement “Computer x is under attack by an intruder.”
Because CS1 is not on the list of computers currently under attack, we conclude that A(CS1) is false.
Similarly, because CS2 and MATH1 are on the list of computers under attack, we know that A(CS2) and A(MATH1) are true.

EXAMPLE 3 Let Q(x, y) denote the statement “x = y + 3.” What are the truth values of the propositions Q(1, 2) and Q(3,0)?
Solution: To obtain Q(1, 2), set x = 1 and y = 2 in the statement Q(x, y). Hence, Q(1, 2) is the statement “1 = 2 + 3,” which is
false. The statement Q(3, 0) is the proposition “3 = 0 + 3,” which is true.

EXAMPLE 4 Let A(c, n) denote the statement “Computer c is connected to network n,” where c is a variable representing
a computer and n is a variable representing a network. Suppose that the computer MATH1 is connected to network
CAMPUS2, but not to network CAMPUS1. What are the values of A(MATH1, CAMPUS1) and A(MATH1, CAMPUS2)?

Solution: Because MATH1 is not connected to the CAMPUS1 network, we see that A(MATH1, CAMPUS1) is false. However,
because MATH1 is connected to the CAMPUS2 network, we see that A(MATH1, CAMPUS2) is true.
PRECONDITIONS AND POSTCONDITIONS The statements that describe valid input are known as preconditions and the
conditions that the output should satisfy when the program has run are known as postconditions.

EXAMPLE 7 Consider the following program, designed to interchange the values of two variables x and y.
temp := x
x := y
y := temp
Find predicates that we can use as the precondition and the postcondition to verify the correctness of this program.
Then explain how to use them to verify that for all valid input the program does what is intended.

Solution: For the precondition, we need to express that x and y have particular values before we run the program. So,
for this precondition we can use the predicate P(x, y), where P(x, y) is the statement “x = a and y = b,” where a and b
are the values of x and y before we run the program. Because we want to verify that the program swaps the values of x
and y for all input values, for the postcondition we can use Q(x, y), where Q(x, y) is the statement “x = b and y = a.” To
verify that the program always does what it is supposed to do, suppose that the precondition P(x, y) holds. That is, we
suppose that the statement “x = a and y = b” is true. This means that x = a and y = b. The first step of the program,
temp := x, assigns the value of x to the variable temp, so after this step we know that x = a, temp = a, and y = b. After
the second step of the program, x := y, we know that x = b, temp = a, and y = b. Finally, after the third step, we know
that x = b, temp = a, and y = a. Consequently, after this program is run, the postcondition Q(x, y) holds, that is, the
statement “x = b and y = a” is true.
Quantifiers

When the variables in a propositional function are assigned values, the resulting statement becomes a proposition with a
certain truth value. However, there is another important way, called quantification, to create a proposition from a
propositional function. Quantification expressesthe 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 quantifications.

We will focus on two types of quantification: universal quantification, which tells us that a predicate is true for every element
under consideration, and existential quantification, which tells us that there is one or more element under consideration for
which the predicate is true.

The area of logic that deals with predicates and quantifiers is called the predicate calculus.

Def: The universal quantification of P(x) is the statement


“P(x) for all values of x in the domain.”
The notation ∀x P(x) denotes the universal quantification of P(x). Here ∀ is called the universal quantifier. We read ∀x P(x) as
“for all x P(x)” or “for every x P(x).” An element for which P(x) is false is called a counterexample to ∀xP(x).

EXAMPLE 8 Let P(x) be the statement “x + 1 > x.” What is the truth value of the quantification ∀xP(x), where
the domain consists of all real numbers?

Solution: Because P(x) is true for all real numbers x, the quantification ∀xP(x) is true.
Quantifiers
Quantifiers
Quantifiers

Def: The existential quantification of P(x) is the proposition


“There exists an element x in the domain such that P(x).”
We use the notation ∃xP(x) for the existential quantification of P(x). Here ∃ is called the existential quantifier.
Quantifiers
QUANTIFIERS OVER FINITE DOMAINS

When the domain of a quantifier is finite, that is, when all its elements can be listed, quantified statements can be
expressed using propositional logic. In particular, when the elements of the domain are x1, x2,…, xn, where n is a positive
integer, the universal quantification ∀xP(x) is the same as the conjunction P(x1) ∧ P(x2) ∧⋯∧ P(xn), because this conjunction is
true if and only if P(x1), P(x2),…, P(xn) are all true.

EXAMPLE 15 What is the truth value of ∀xP(x), where P(x) is the statement “x2< 10” and the domain consists of the
positive integers not exceeding 4?

Solution: The statement ∀xP(x) is the same as the conjunction P(1) ∧ P(2) ∧ P(3) ∧ P(4), because the domain consists of
the integers 1, 2, 3, and 4. Because P(4), which is the statement “42< 10,” is false, it follows that ∀xP(x) is false.

Similarly, when the elements of the domain are x1, x2,…, xn, where n is a positive integer, the existential quantification ∃xP(x)
is the same as the disjunction P(x1) ∨ P(x2) ∨⋯∨ P(xn), because this disjunction is true if and only if at least one of P(x1),
P(x2),…, P(xn) is true.

EXAMPLE 16 What is the truth value of ∃xP(x), where P(x) is the statement “x2 > 10” and the universe of discourse
consists of the positive integers not exceeding 4?

Solution: Because the domain is {1, 2, 3, 4}, the proposition ∃xP(x) is the same as the disjunction P(1) ∨ P(2) ∨ P(3) ∨ P(4).
Because P(4), which is the statement 42 >10,” is true, it follows that ∃xP(x) is true.
Quantifiers with Restricted Domains

An abbreviated notation is often used to restrict the domain of a quantifier. In this notation, a condition a variable must
satisfy is included after the quantifier. This is illustrated in Example 17.

EXAMPLE 17 What do the statements ∀x < 0 (x2 > 0), ∀y ≠ 0 (y3 ≠ 0), and ∃z > 0 (z2 = 2) mean, where the domain in each
case consists of the real numbers?

Solution: The statement ∀x < 0 (x2 > 0) states that for every real number x with x < 0, x2 > 0. That is, it states
“The square of a negative real number is positive.”
This statement is the same as ∀x(x < 0 → x2 > 0).
The statement ∀y ≠ 0 (y3 ≠ 0) states that for every real number y with y ≠ 0, we have y3 ≠0. That is, it states
“The cube of every nonzero real number is nonzero.”
This statement is equivalent to ∀y(y ≠ 0 → y3 ≠ 0).
Finally, the statement ∃z > 0 (z2 = 2) states that there exists a real number z with z > 0 such that z2 = 2. That is, it states
“There is a positive square root of 2.”
This statement is equivalent to ∃z(z > 0 ∧ z2 = 2).

Precedence of Quantifiers
The quantifiers ∀ and ∃ have higher precedence than all logical operators from propositional calculus. For example, ∀xP(x)
∨ Q(x) is the disjunction of ∀xP(x) and Q(x). In other words, it means (∀xP(x)) ∨ Q(x) rather than ∀x(P(x) ∨ Q(x)).
Binding Variable

When a quantifier is used on the variable x, we say that this occurrence of the variable is bound.
An occurrence of a variable that is not bound by a quantifier or set equal to a particular value is said to be free.
The part of a logical expression to which a quantifier is applied is called the scope of this quantifier.
Consequently, a variable is free if it is outside the scope of all quantifiers in the formula that specify this variable.

EXAMPLE 18 In the statement ∃x(x + y = 1), the variable x is bound by the existential quantification ∃x, but the
variable y is free because it is not bound by a quantifier and no value is assigned to this variable. This illustrates that
in the statement ∃x(x + y = 1), x is bound, but y is free.

EXAMPLE 19 In the statement ∃x(P(x) ∧ Q(x)) ∨ ∀xR(x), all variables are bound. The scope of the first quantifier, ∃x,
is the expression P(x) ∧ Q(x), because ∃x is applied only to P(x) ∧ Q(x) and not to the rest of the statement. Similarly,
the scope of the second quantifier, ∀x, is the expression R(x). That is, the existential quantifier binds the variable x
in P(x) ∧ Q(x) and the universal quantifier ∀x binds the variable x in R(x). Observe that we could have written our
statement using two different variables x and y, as ∃x(P(x) ∧ Q(x)) ∨ ∀yR(y), because the scopes of the two
quantifiers do not overlap.

You might also like