0% found this document useful (0 votes)
8 views14 pages

Lec 6&7

The document discusses predicates and quantifiers in predicate logic, highlighting their importance in expressing complex statements beyond simple true or false values. It explains the universal and existential quantifiers, providing examples of how predicates can be evaluated based on assigned variable values. Additionally, it covers preconditions and postconditions in programming, emphasizing their role in verifying program correctness.

Uploaded by

pochinkisu075
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)
8 views14 pages

Lec 6&7

The document discusses predicates and quantifiers in predicate logic, highlighting their importance in expressing complex statements beyond simple true or false values. It explains the universal and existential quantifiers, providing examples of how predicates can be evaluated based on assigned variable values. Additionally, it covers preconditions and postconditions in programming, emphasizing their role in verifying program correctness.

Uploaded by

pochinkisu075
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/ 14

DISCRETE STRUCTURES AND THEORY OF LOGIC (BCS 303)

Lecture - 6

Predicates and Quantifiers


In propositional logic, statements are either true or false, but this can be limiting. Predicate
logic is more powerful and allows us to express more complex ideas by using predicates and
quantifiers.
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.”

A predicate represents a property or relationship between objects.


For example, "x is a prime number" is a predicate because it states something about the
object x.

Quantifiers let us express how many objects a predicate applies to:


1. Universal quantifier ( ∀ ): States that a predicate is true for all objects in a domain.
Example: "Every computer is functioning properly" can be written as
∀x (Computer(x) → Working(x))
“For every computer x, if x is a computer, then x is working.”
2. Existential quantifier ( ∃ ): States that there is at least one object for which the
predicate is true.
Example: "There is a computer under attack" becomes
∃x (Computer(x) ∧ Under Attack(x))
“There exists at least one computer that is under attack."
With these tools, we can express more complex mathematical and logical ideas. For example,
we can reason about all objects of a certain type or find at least one object with a specific
property.
This is especially useful in computer science and mathematics when reasoning about large
sets of objects or abstract concepts.
Predicates
Predicates are statements involving variables. They are not true or false until you specify
the values of the variables.
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,”

Components of a Predicate:
x is greater than 3
• Subject: The variable (e.g., x, y, z).
• Predicate: The property or condition (e.g., “is greater than 3”, “is under attack by an
intruder”).
• We can denote the statement “x is greater than 3” by P(x)
• The statement P(x) is also said to be the value of the propositional function P at x.
• Converting Predicates to Propositions: Once a value has been assigned to the
variable x, the statement P(x) becomes a proposition and has a truth value.

EXAMPLE1: Let P(x) denote the statement “x > 3”. What are the truth values of P(4) and
P(2)?
Solution: Predicate: P(x) = “x > 3”
P(4): “4 > 3” → True
P(2): “2 > 3” → False

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: Predicate: A(x) = “Computer x is under attack by an intruder”
A(CS1): CS1 is not under attack → False
A(CS2): CS2 is under attack → True
A(MATH1): MATH1 is under attack → True
Predicates with Multiple Variables:
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: Predicate: Q(x, y) = “x = y + 3”
Q(1, 2): “1 = 2 + 3” → False
Q(3, 0): “3 = 0 + 3” → True
Key Points:
• Predicates become propositions when variable values are assigned.
• Truth values depend on the specific values of the variables.
• Examples show how to evaluate predicates with given values to determine their truth.

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: Predicate: A(c, n): “Computer c is connected to network n”
A(MATH1, CAMPUS1): False (MATH1 is not connected to CAMPUS1)
A(MATH1, CAMPUS2): True (MATH1 is connected to CAMPUS2)

EXAMPLE 5: What are the truth values of the propositions R(1,2,3) and R(0,0,1)?
Let R(x,y,z) denote the statement “x + y = z.” When values are assigned to the variables x,
y, and z, this statement has a truth value.
Solution: R(x, y, z): “x + y = z”
R(1, 2, 3): True (1 + 2 = 3)
R(0, 0, 1): False (0 + 0 ≠ 1)

General Statements:

• A statement with variables x1, x2, ..., xn can be written as P(x1,x2,...,xn).

• This type of statement shows whether a condition P is true or false when specific
values are plugged into the variables x1, x2, ..., xn.

• P is called an n-place predicate or an n-ary predicate because it involves n variables.

EXAMPLE 6: Consider the statement


if x > 0 then x := x +1

• In the statement if x > 0 then x := x +1 the program checks if x is greater than 0.


• If x is greater than 0 (making P(x) true), the program updates x by adding 1 to it.
• If x is not greater than 0 (making P(x) false), the program does nothing and x remains
the same.

Preconditions and Postconditions:


• Preconditions: These are the conditions that must be true before a computer program
runs. They describe the valid inputs or starting state that the program expects. If the
preconditions aren't met, the program might not work correctly or produce the desired
results.
• Postconditions: These are the conditions that should be true after the program has
run. They describe what the program is supposed to accomplish or the expected results
based on the valid inputs provided.
In short:
• Preconditions are the requirements before the program runs.
• Postconditions are the results expected after the program runs.
Example
Let's say we have a program that swaps the values of two variables, x and y.
Preconditions:
• Before running the program, we need to know the initial values of x and y. For example,
x could be a and y could be b.
Postconditions:
• After the program runs, the values of x and y should be swapped. So, x should be b
and y should be a.
By checking these conditions, we can ensure the program works correctly for all valid inputs.

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:
We have a program that is supposed to swap the values of two variables, x and y. So, if x
starts with value a and y starts with value b, after running the program, x should have the
value b and y should have the value a.
Precondition:
The precondition is what we know before the program starts. In this case, we know that the
values of x and y are a and b, respectively. We write this as:
P(x, y): "x = a and y = b."
Postcondition:
The postcondition is what we expect after the program runs. We expect that x now holds y's
original value (which was b), and y holds x's original value (which was a). We write this as:
Q(x, y): "x = b and y = a."
Steps of the program:
• First, the program stores the value of x in a temporary variable (temp), so temp has
the value of a (since x = a). Now we know that temp = a, x = a, and y = b.
• Then, the program assigns the value of y to x. So now, x = b (since y = b), while temp
still holds a, and y is still b.
• Finally, the program assigns the value of temp (which is a) to y. So now, y = a.
At the end, we have x = b and y = a, which is exactly what we wanted in the postcondition.
Conclusion:
By following the steps of the program and checking the values of x, y, and temp at each step,
we can verify that the program correctly swaps the values of x and y.

Quantifiers
• Quantifiers are a way to turn a propositional function into a proposition by specifying
how true the statement is across a range of elements.
• When we assign values to variables in a propositional function, it becomes a
proposition with a truth value.
• Quantification helps express how much of the statement is true.
• Words like all, some, many, none, and few are used in quantification.
• There are two main types of quantification:
▪ Universal Quantification: The statement is true for every element in the set.
▪ Existential Quantification: The statement is true for at least one element in
the set.
• The area of logic that deals with predicates (statements with variables) and quantifiers
is called predicate calculus.

Universal quantifier
The universal quantifier is used in mathematical statements to say that a property is true
for all values of a variable within a specific set, called the domain of discourse (or simply,
the domain).
When we use universal quantification for the statement P(x), it means that P(x) is true for
every value of x in the domain. The domain tells us the possible values that x can take.
The meaning of the universal quantification can change if we change the domain. That's why
the domain must always be specified when using a universal quantifier. Without specifying
the domain, the universal quantification of a statement is undefined.
Let’s say the statement is:
• "For all x, x is greater than 0."
Now, the meaning of this statement changes based on the domain of x:
1. If the domain is positive integers, the statement means "For all positive integers x, x
is greater than 0." This is true.
2. If the domain is all integers, the statement means "For all integers x, x is greater than
0." This is false because negative integers and zero exist in this domain.

DEFINITION:
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 of ∀x P(x).

Quantifiers:
Statement When True? When False?
∀x P(x) P(x) is true for every x. There is an x for which P(x) is false.
∃x P(x) There is an x for which P(x) is true. P(x) is false for every x.

EXAMPLE 8: Let P(x) be the statement “x +1 > x.” What is the truth value of the
quantification ∀x P(x), where the domain consists of all real numbers?
Solution: Since adding 1 to any real number x will always make it bigger than x, the
statement is true for all real numbers. Therefore, the statement ∀x P(x) is true.

Important Remark:
• The domain (the set of numbers we are considering) must always be non-empty. If the
domain were empty (no numbers at all), ∀x P(x) would automatically be true because
there would be no number x that could make P(x) false.
• The truth of ∀x P(x) depends on the domain. For example, if the domain were just a
set of specific numbers, the result might change.

➢ The universal quantifier "∀" can be expressed in many ways:


for all for every all of for each

given any for arbitrary for any -

Remark: It is best to avoid using “for any x” because it is often ambiguous as to whether
“any” means “every” or “some.”
In some cases, “any” is unambiguous, such as when it is used in negatives, for example,
“there is not any reason to avoid studying.”

Example 9: Let Q(x) be the statement "x < 2". What is the truth value of ∀x Q(x), where the
domain is all real numbers?
Solution: This is false because not every real number is less than 2.
For example, Q(3) (when x = 3) is false since 3 is greater than 2.
So, x = 3 is a counterexample that proves ∀x Q(x) is false.
Important Remark:
• To show that a statement like ∀x P(x) is false, all you need is a single counterexample.
If even one x in the domain makes the statement P(x) false, then ∀x P(x) is false.

Example: Let P(x) be the statement "x² > 0," where the domain consists of all integers.
• To prove that ∀x P(x) (i.e., "x² > 0 for all x") is false, we need to find a
counterexample.
• A counterexample is a value of x that makes P(x) false.
• In this case, x = 0 is a counterexample because 02 = 0, which is not greater than 0.
o Therefore, the statement ∀x P(x) is false.
Important Point:
• Looking for counterexamples is a crucial technique in mathematics to disprove
universally quantified statements (statements that are true for all elements of a set).

When the domain has a limited number of elements:


• If you can list all elements in the domain (for example, x1, x2,…, xn), then the
statement ∀x P(x) can be written as the conjunction (AND operation):
P(x1) ∧ P(x2) ∧ ⋯ ∧ P(xn)
• This means ∀x P(x) is true if and only if all the individual statements
P(x1),P(x2),…,P(xn) are true.
• In simple terms: to say that "P(x) is true for all elements" is the same as saying "P(x)
is true for each individual element one by one."

Example: What is the truth value of ∀x P(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 ∀x P(x) is false.
Example: What does the statement ∀x N(x) mean if N(x) is “Computer x is connected to
the network” and the domain consists of all computers on campus?
Solution: Statement: ∀x N(x)
• ∀x: This symbol means "for all" or "every."
• N(x): This represents the statement "Computer x is connected to the network."
• Domain: The domain here consists of all computers on campus.
• ∀x N(x) means that the statement N(x) ("Computer x is connected to the network") is
true for every computer x in the domain (i.e., every computer on campus).
This statement can be expressed in English as
"Every computer on campus is connected to the network."
This means that if you pick any computer on campus, it will definitely be connected to the
network. There are no exceptions; all computers on campus are connected to the network.

Example: What is the truth value of ∀x (x2 ≥ x) if the domain consists of all real
numbers? What is the truth value of this statement if the domain consists of all
integers?
Solution: Domain 1: All Real Numbers
• Statement: ∀x (x2 ≥ x) means "For every real number x, x2 ≥ x."
• Counterexample: For x=1/2, (1/2)2 = 1/4, which is less than 1/2.
• Conclusion: The statement is false because there are real numbers where x2 < x.

Domain 2: All Integers


• Statement: ∀x (x2 ≥ x) means "For every integer x, x2 ≥ x."
• Analysis: For all integers, x2 is always greater than or equal to x.
• Conclusion: The statement is true because there are no integers where x2 < x.

Example: Let D={1,2,3,…,9}. Determine the truth value of the following statements:
(a) (∀x ∈ D) x + 4 < 15
(b) (∃x ∈ D) x + 4 = 10
(c) (∀x ∈ D) x + 4 ≤ 10
(d) (∃x ∈ D) x + 4 > 15
Solution:
(a) (∀x ∈ D) x + 4 < 15
This statement asserts that for every x in D, x + 4 < 15.
For every x ∈ D, the result of x+4 is as follows:
• For x = 1, 1 + 4 = 5
• For x = 2, 2 + 4 = 6
• For x = 3, 3 + 4 = 7
• For x = 4, 4 + 4 = 8
• For x = 5, 5 + 4 = 9
• For x = 6, 6 + 4 = 10
• For x = 7, 7 + 4 = 11
• For x = 8, 8 + 4 = 12
• For x = 9, 9 + 4 = 13
All of these values are less than 15, so the statement is true.
(b) (∃x ∈ D) x + 4 = 10
This statement asserts that there exists an x in D such that x + 4 = 10.
For x = 6, we have 6 + 4 = 10. Therefore, such an x exists, and the statement is true.
(c) (∀x ∈ D) x + 4 ≤ 10
This statement asserts that for every x in D, x + 4 is less than or equal to 10.
When x = 7, we have 7 + 4 =11, which is greater than 10. Thus, the statement is false.
(d) (∃x ∈ D) x + 4 > 15
This statement asserts that there exists an x in D such that x + 4 > 15.
For all x ∈ D, we find that:
• 1+4=5
• 2+4=6
• 3+4=7
• 4+4=8
• 5+4=9
• 6+4=1
• 7+4=11
• 8+4=12
• 9+4=13
None of these values exceed 15. Therefore, the statement is false.
Translating Sentences into Logical Expressions
Logical operators and quantifiers can be used to express English sentences into logical
expressions. Consider, for example, the sentence:
"Every person is precious."
This can be translated as:
For every x, if x is a person, then x is precious.
In ordinary grammar, "is precious" is the predicate of this sentence.
In the logical expression, we add the predicate "is a person" to represent the common noun
"person" in the sentence. Let:
• M(x) represent "x is a person",
• A(x) represent "x is precious".
Thus, the sentence can be written as:
∀x (M(x) → A(x))
or, equivalently:
∀x (M(x) ∧ A(x))
Statements containing words like "every," "each," or "everyone" usually indicate a
universal quantifier. Such statements are typically rephrased to start with "For every x,"
which is denoted by ∀x.
Why two predicates?
• The sentence "Every person is precious" actually involves two ideas:
1. The subject (we are talking about "people").
2. The property (those people are "precious").
In logical notation, we break these two ideas into separate predicates:
• M(x): This tells us the subject (whether "x is a person").
• A(x): This tells us the property (whether "x is precious").
2. Why not just one predicate?
If we only use A(x) (i.e., "x is precious"), we lose the information about who is precious. In
this case, we are specifically talking about people being precious, so we need to express
that x is a person before saying they are precious.
3. The Role of Logic
In logic, we break down sentences into their simplest components. "Person" is a category,
and "precious" is a quality. We use two predicates because:
• M(x) checks if something (x) is a person.
• A(x) says if that person is precious.
Without both, we couldn't specify that we're talking about people being precious.

Example: "Some student of this college passed the MCA entrance examination."
We can translate this sentence as:
"There exists a student of this college who passed the MCA entrance examination."
Predicates:
• S(x): "x is a student of this college."
• p(x): "x passed the MCA entrance examination."
Logical Expression: ∃x (S(x) ∧ p(x))
• ∃x: "There exists an x such that..."
• S(x) ∧ p(x): "x is a student of this college and x passed the MCA entrance examination."

Statements containing phrases like "some" or "at least one" suggest existential
quantification. They are rephrased as "There exists an x such that" and are translated
using ∃x.

Example: Express the Following Statements Using Quantifiers


Let:
• K(x): x is a man,
• L(x): x is mortal,
• M(x): x is an integer,
• N(x): x is either positive or negative.
(a) "All men are mortal."
(b) "Any integer is either positive or negative."
Solutions:
(a) "All men are mortal."
The given sentence can be written as:
For all x, if x is a man, then x is mortal.
In symbolic form:
∀x (K(x) → L(x))
(b) "Any integer is either positive or negative."
The given sentence can be written as:
For all x, if x is an integer, then x is either positive or negative.
In symbolic form:
∀x (M(x) → N(x))

Example: Express the Following Using Quantifiers


Let:
• K(x): x is a student,
• M(x): x is clever,
• N(x): x is successful.
(a) "There exists a student."
In symbolic form:
∃x (K(x))
(b) "Some students are clever."
This can be written as:
There exists an x such that x is a student and x is clever.
In symbolic form:
∃x (K(x) ∧ M(x))
(c) "Some students are not successful."
This can be written as:
There exists an x such that x is a student and x is not successful.
In symbolic form:
∃x (K(x) ∧ ¬N(x))

Negation of Quantified Statements


1. Universal Quantification and Its Negation:
Original Statement: "All students in the class have taken a course in discrete
mathematics."
▪ Logical Form: ∀x P(x)
▪ Where: P(x) means "x has taken a course in discrete mathematics."
Negation of the Statement:
"It is not the case that all students in the class have taken a course in discrete mathematics."
▪ Logical Form: ¬(∀x P(x))

To find the equivalent statement:


▪ Apply Negation: The negation of a universal quantifier (∀) becomes an existential
quantifier (∃), and the predicate inside gets negated.
▪ Equivalence: ¬(∀x P(x)) ≡ ∃x ¬P(x)
▪ Statement becomes: "There is a student in the class who has not taken a course
in discrete mathematics."
▪ This means that if a statement says "all are," its negation says "some are not."

2. Existential Quantification and Its Negation:


Original Statement: "There is a student in this class who has taken a course in
discrete mathematics."
▪ Logical Form: ∃x Q(x)
▪ Where: Q(x) means "x has taken a course in discrete mathematics."
Negation of the Statement:
"It is not the case that there is a student in this class who has taken a course in discrete
mathematics."
▪ Logical Form: ¬(∃x Q(x))
To find the equivalent statement:
▪ Apply Negation: The negation of an existential quantifier (∃) becomes a universal
quantifier (∀), and the predicate inside gets negated.
▪ Equivalence: ¬(∃x Q(x)) ≡ ∀x ¬Q(x)
▪ Statement becomes: "All students in this class have not taken a course in
discrete mathematics."
▪ This means that if a statement says "some are," its negation says "all are not."

We list these facts as follows:


Statement Negation
All true ∀x F(x) ∃x [¬F(x)] At least one false
At least one false ∃x [¬F(x)] ∀x F(x) All true
All false ∀x [¬F(x)] ∃x F(x) At least one true
At least one true ∃x F(x) ∀x [¬F(x)] All false

In general, the negation of a quantifier follows these rules:


• Negation of ∀ becomes ∃
• Negation of ∃ becomes ∀
• Negate the predicate
The rules for negations for quantifiers are called De Morgan’s laws for quantifiers.
¬∃x P(x) ≡ ∀x ¬P(x)
¬∀x P(x) ≡ ∃x ¬P(x)

Example: Negating a Conditional Statement


• Statement: "For all real numbers x, if x > 3 then x2 > 9."
Let:
▪ P(x): "x > 3"
▪ Q(x): "x2 > 9"
Logical Form: ∀x (P(x) → Q(x))
Negation of the Statement:
"There exists a real number x such that x > 3 and x2 ≤ 9."
▪ Logical Form: ¬(∀x(P(x)→Q(x)))
To find the equivalent statement:
▪ Apply Negation: The negation of a universal quantifier (∀) is an existential
quantifier (∃), and we negate the implication.
▪ Apply Implication Negation: P(x)→Q(x) is equivalent to ¬P(x) ∨ Q(x). Its negation
is P(x) ∧ ¬Q(x).
▪ Equivalence: ¬(∀x (P(x) → Q(x))) ≡ ∃x (P(x) ∧ ¬Q(x))
▪ Statement becomes: "There exists a real number x such that x>3 and x2 ≤ 9."

You might also like