You are on page 1of 37

CSC102:Discrete Structure

Instructor : Khurram Iqbal

Department of Computer Science


COMSATS University, Islamabad
Recap

Lecture No 4

Department of Computer Science 2


Propositional Logic

 Propositional logic is
 the study of propositions (true or false statements)
and
 The ways of combining them (logical operators) to
get new propositions.

Department of Computer Science


Review: Propositional Logic

 Atomic propositions: p, q, r, …
 Boolean operators:      
 Compound propositions: s  (p  q)  r
 Equivalences: pq  (p  q)
 Proving equivalences using:
 Truth tables.
 Symbolic derivations. p  q  r …

Department of Computer Science


Valid and Invalid Arguments

 An argument (form) is a sequence of


statements (statement forms).
 All statements (statement forms) but the last are
called premises, hypotheses, or assumptions.
 The last statement (form) is called the
conclusion.
 The conclusion is preceded by “” (said
“therefore”).
 An argument (form) is valid if whenever its
premises are true, then its conclusion is also
true.
Department of Computer Science
Testing an Argument Form for Validity

 Identify the premises and conclusion of the


argument form.
 Construct a truth table showing the truth values
of all the premises and the conclusion.
 A row of the truth table in which all the
premises are true is called a critical row.

Department of Computer Science


Testing an Argument Form for Validity

 If there is a critical row in which the conclusion


is false, then it is possible for an argument of the
given form to have true premises and a false
conclusion, and so the argument form is invalid. If
the conclusion in every critical row is true, then
the argument form is valid.

Department of Computer Science


Additional Valid Argument Forms: Rule of Inference

A rule of inference is a form of argument that


is valid.

Department of Computer Science


Today Covered

After completing this lecture you will be able to


understand:
 The Logic of Quantified Statements
 Predicates and Quantified Statements

Department of Computer Science


Why not Propositional Logic?

 Consider the statements that we encountered in


mathematics, computer programs, and in
system specifications such as:
 p: n is an odd integer.
 q: computer x is under attack by an intruder
 r: computer y is functioning properly.
 These statements are neither true nor false
when the values of the variables are not
specified.

Department of Computer Science


Predicate Logic

 Therefore, the propositional logic, studied so far,


cannot adequately express the meaning of all
statements in mathematics and computer
science.
 Since most of the statements in mathematics
and computer science use variables, we must
extend the system of logic to include such
statements.
 In this lecture we will introduce a more powerful
type of logic called predicate logic

Department of Computer Science


Predicate

 To understand predicate logic, we first need to


introduce the concept of a predicate.
 A predicate(a.k.a propositional function) is
a sentence that contains a finite number of
variables and becomes a statement when specific
values are substituted for the variables.
 Anatomy of Predicate:

P(x) = x + 5 > x

variable predicate

Department of Computer Science


Propositional Function

 Consider P(x) = x < 5


 P(x) has no truth values (x is not given a value)
 P(1) is true
 The proposition 1<5 is true
 P(10) is false
 The proposition 10<5 is false
 Thus, P(x) will create a proposition when given
a value

Department of Computer Science 13


Propositional Function

 Let P(x) = “x is a multiple of 5”


 For what values of x is P(x) true?
 Let P(x) = x+1 > x
 For what values of x is P(x) true?
 The set of all values that may be substituted in
place of the variable is called domain of a
predicate variable.

Department of Computer Science 14


Propositional Function

 Functions with multiple variables:

 P(x,y) = x + y == 0
 P(1,2) is false, P(1,-1) is true

 P(x,y,z) = x + y == z
 P(3,4,5) is false, P(1,2,3) is true

 P(x1,x2,x3 … xn) = …

Department of Computer Science 15


Example

 Let A(c,n): “computer c is connected to


network n”
 Suppose that the computer MATH1 is connected
to network CAMPUS2, but not to network
CAMPUS1
 What are the truth values of
 A(MATH1, CAMPUS1) and
 A(MATH1, CAMPUS2) ?

Department of Computer Science 16


Your Turn

 Let Q(x, y, z): x2 + y2 = z2.


 What is the truth value of Q(3, 4, 5)?
 What is the truth value of Q(2, 2, 3)?
 How many values of (x, y, z) make the predicate
true?

Department of Computer Science 17


UPSHOT

Let P(x) be a statement involving the variable x and


let D be a set. We call P a predicate (with respect to D)
or propositional function if for each x ∈ D, P(x) is a
proposition. We call D the domain of discourse of P.

Department of Computer Science


Quantifiers

 A predicate becomes a proposition when we


assign it fixed values.
 However, another way to make a predicate
into a proposition is to quantify it.
 Consider the following statements:
 All people are mortal
 Every computer is a 16 bit-machine
 No birds are black
 Some people have blue eyes
 There exist an even prime number.

Department of Computer Science


Quantifiers

 Consider the following statements:


 All people are mortal
 Every computer is a 16 bit-machine
 No birds are black
 Some people have blue eyes
 There exist an even prime number.
 Each contains a word indicating the quantity
such as all, every, none, some, and one.
 Such words, called quantifiers, gives us an idea
about how many objects have a certain
property.
Department of Computer Science
Quantifiers

 Quantifiers are words that refer to quantities


such as "some" or "all" and tell for how many
elements a given predicate is true.
 That is, the predicate is true (or false) for all
possible values in the universe of discourse or for
some value(s) in the universe of discourse.

Department of Computer Science


Quantifier

 A quantifier is “an operator that limits the


variables of a proposition”
 Two types:
 Universal
 Which tell us that a predicate is true for every element
under consideration.
 Existential
 Which tell us that there is one or more element under
consideration for which the predicate is true.

Department of Computer Science 22


Universal Quantifier

 Represented by an upside-down A: 
 It means “for all”, “for each”, “for every”
 If the universe of discourse is finite, say {n1, n2, . . ,
nk}, then the universal quantifier is simply the
conjunction of all elements:

 We can state the following:


 x P(x)
 English translation: “for all values of x, P(x) is true”
 Let P(x) = x+1 > x
 English translation: “for all values of x, x+1>x is
true”
Department of Computer Science 23
Universal Quantifier

 But is that always true?


 x P(x)
 Let x = the character ‘a’
 Is ‘a’+1 > ‘a’?
 Let x = the city of Pakistan
 Is x+1 > x?
 You need to specify your universe!
 What values x can represent
 Called the “domain” or “universe of discourse” by the
textbook

Department of Computer Science 24


Universal Quantifier

 In order to prove that a universal quantification


is true, it must be shown for ALL cases

 In order to prove that a universal quantification


is false, it must be shown to be false for only
ONE case

Department of Computer Science 25


Universal Quantifier

 Think of  as a for loop:

 x P(x), where 1 ≤ x ≤ 10 … can be translated as …

for ( x = 1; x <= 10; x++ )


is P(x) true?

 If P(x) is true for all parts of the for loop, then x P(x)
 Consequently, if P(x) is false for any one value of the for loop,
then x P(x) is false

Department of Computer Science 26


Existential Quantifier

 Represented by an backwards E: 
 It means “there exists a”, “some”, for at least one
 If the universe of discourse is finite, say {n1, n2, . . ,
nk}, then the universal quantifier is simply the
disjunction of all elements:

 We can state the following:


 x P(x)
 English translation: “there exists (a value of) x such
that P(x) is true”
 Let P(x) = x+1 > x
 English translation: “for at least one value of x,
x+1>x is true”
Department of Computer Science 27
Existential Quantifier

 Note that you still have to specify your universe


 Let P(x) = x+1 < x
 There is no numerical value x for which x+1<x
 Thus, x P(x) is false
 Let P(x) = x+1 > x
 There is a numerical value for which x+1>x
 In fact, it’s true for all of the values of x!
 Thus, x P(x) is true

Department of Computer Science 28


Existential Quantifier

 In order to show an existential quantification is


true, you only have to find ONE value
 In order to show an existential quantification is
false, you have to show it’s false for ALL values

Department of Computer Science 29


UPSHOT

 Recall that P(x) is a propositional function


 Let P(x) be “x == 0”
 Recall that a proposition is a statement that is either
true or false
 P(x) is not a proposition
 There are two ways to make a propositional function
into a proposition:
 Supply it with a value
 For example, P(5) is false, P(0) is true
 Provide a quantification
 For example, x P(x) is false and x P(x) is true
 Let the universe of discourse be the real numbers

Department of Computer Science 30


UPSHOT

Truth Values of Quantifiers

Department of Computer Science


Negating Quantified Expressions

 Consider the statement:


 All students in this class have red hair
 What is required to show the statement is false?
 There exists a student in this class that does NOT
have red hair
 To negate a universal quantification:
 You negate the propositional function
 AND you change to an existential quantification
 ¬x P(x)  x ¬P(x)

Department of Computer Science 32


Your Turn

 Write the negation of the statement


 “Every student in your class has taken a course in
calculus.”
 Let P(x) :“x has taken a course in calculus”
 and the domain consists of the students in your
class.
 Now the given statement is a universal
quantification, namely, ∀xP(x),
 The negation of this statement is:
 “There is a student in your class who has not
taken a course in calculus.” ∃x ¬ P(x).
Department of Computer Science
Negating Quantified Expressions

 Consider the statement:


 There is a student in this class with red hair
 What is required to show the statement is false?
 All students in this class do not have red hair
 Thus, to negate an existential quantification:
 You negate the propositional function
 AND you change to a universal quantification
 ¬x P(x) = x ¬P(x)

Department of Computer Science 34


Your Turn

 Negate the following statement:


 “There is a student in this class who has taken a
course in calculus.”
 Let Q(x) :“x has taken a course in calculus
 This is the existential quantification ∃xQ(x)
 The negation of this statement is the
proposition
 Every student in this class has not taken
calculus
∀x ¬ Q(x).

Department of Computer Science


Upshot

Department of Computer Science


Translating from English into Logical Expressions

 From Book

Department of Computer Science

You might also like