0% found this document useful (0 votes)
27 views

CH # 1 (Logic and Proofs)

The document is about discrete structures and logic. It discusses the goals of a discrete mathematics course which are to teach students logical and mathematical thinking as well as working with discrete structures like sets, graphs, and finite state machines. It then defines discrete and continuous data, giving examples of each. The rest of the document discusses propositional logic, including defining propositions, logical operators like conjunction and disjunction, and truth tables for logical expressions. It aims to teach students logical reasoning and applying logic to problems.

Uploaded by

Muhammad Imran
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)
27 views

CH # 1 (Logic and Proofs)

The document is about discrete structures and logic. It discusses the goals of a discrete mathematics course which are to teach students logical and mathematical thinking as well as working with discrete structures like sets, graphs, and finite state machines. It then defines discrete and continuous data, giving examples of each. The rest of the document discusses propositional logic, including defining propositions, logical operators like conjunction and disjunction, and truth tables for logical expressions. It aims to teach students logical reasoning and applying logic to problems.

Uploaded by

Muhammad Imran
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/ 46

DISCRETE STRUCTURES

Chapter # 1
Logic and Proofs

By:
Muhammad Imran
Assistant Prof. of Computer Science
Govt. Millat Graduate College Mumtazabad, Multan

Lecturer (Visiting Faculty) of I.T


Women University, Multan
2 DISCRETE STRUCTURES

Goals of a Discrete Mathematics Course


A discrete mathematics course has more than one purpose. Students should learn a
particular set of mathematical facts and how to apply them; more importantly,
such a course should teach students how to think logically and mathematically.
Five important themes are interwoven in this text:
1. Mathematical Reasoning,
2. Combinatorial Analysis,
3. Discrete Structures,
4. Algorithmic thinking, and applications
5. Modeling.
Discrete Structures:
A course in discrete mathematics should teach students how to
work with discrete structures, which are the abstract mathematical structures used
to represent discrete objects and relationships between these objects. These
discrete structures include sets, permutations, relations, graphs, trees, and
finite-state machines.

What is Discrete Data?


Discrete data also referred to as discrete values, is data that only takes certain values.
Commonly in the form of whole numbers or integers, this is data that can be counted and has
a finite number of values. These values must be able to fall within certain classifications and
are unable to be broken down into smaller parts.

Some examples of discrete data would include:

 The number of employees in your department


 The number of new customers you signed on last quarter
 The number of products currently held in inventory

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
3 DISCRETE STRUCTURES

What is Continuous Data?


Continuous data refers to data that can be measured. This data has values that are not fixed
and have an infinite number of possible values. These measurements can also be broken
down into smaller individual parts.

Some examples of continuous data would include:

 The height or weight of a person


 The daily temperature in your city
 The amount of time needed to complete a task or project

What is Discrete Structures?


Discrete Structures is a part of Mathematics devoted to the study of discrete objects.

Applications of Discrete Mathematics:


1. How can circuit that adds two integers be designed?

2. How many ways are there to choose a valid password on a computer?

3. What is the shortest path between two cities using transportation system?

4. How can I encrypt a message so that no unintended recipient can read it?

5. How many valid internet addresses are there?

6. How can a list of integers be sorted so that the integers are in increasing
order.

Logic: way of thinking


This means the goal of logic is to use data to make inferences. For example, if a
person walked into a room and saw children holding markers and then saw marker
scribbles all over the walls, logic would dictate that from the given the information
presented, the children drew all over the walls with markers.
Prepared By: Muhammad Imran
Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
4 DISCRETE STRUCTURES

 Propositional Logic

 Logic of Compound Statement

 Propositional Equivalnces

 Conditional Statements

 Logical Equivalences

 Valid and Invalid Arguments

 Applications: Digital Logic Circuits

 Predicates and Quantifiers

Propositional Logic
A proposition is a declarative sentence (that is, a sentence that declares a fact) that is
either true or false, but not both.

EXAMPLE 1 All the following declarative sentences are propositions.


1. Washington, D.C., is the capital of the United States of America.
2. Toronto is the capital of Canada.
3. 1 + 1 = 2.
4. 2 + 2 = 3.
Propositions 1 and 3 are true, whereas 2 and 4 are false.

Some sentences that are not propositions are given in Example 2.

EXAMPLE 2 Consider the following sentences.


1. What time is it?
2. Read this carefully.
3. x + 1 = 2.
4. x + y = z.
Sentences 1 and 2 are not propositions because they are not declarative sentences. Sentences 3
and 4 are not propositions because they are neither true nor false. Note that each of sentences 3
and 4 can be turned into a proposition if we assign values to the variables.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
5 DISCRETE STRUCTURES

More Examples:

Are the following sentences propositions? If it is a proposition, determine


whether it is true or false.

1. Paris is the capital of France

It is declarative statement and hence is a proposition. This proposition is a TRUE(T)

1. Can Asma come with you?

It is not a declarative sentence hence not a proposition.

2. Take two panadols

This is an imperative sentence hence not a proposition.

3. X+4>9

This is not a proposition because it is true for certain values of x and false for certain values of x

4. She is a college student

This is not a proposition because truth or falsity of this proposition depends on the reference of
pronoun she. This can be converted into proposition by the following way:

She is studying in graduation and is a college student.

Notations
We use letters to denote propositional variables (or statement variables), that is,
variables that represent propositions, just as letters are used to denote numerical
variables. The conventional letters used for propositional variables are p, q, r, s, . . . . The
truth value of a proposition is true, denoted by T or 1, if it is a true proposition, and the
truth value of a proposition is false, denoted by F or 0, if it is a false proposition.

The area of logic that deals with propositions is called the propositional calculus or
propositional logic. It was first developed systematically by the Greek philosopher
Aristotle more than 2300 years ago. Many mathematical statements are constructed by
combining one or more propositions. New propositions, called compound propositions,
are formed from existing propositions using logical operators.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
6 DISCRETE STRUCTURES

Compound Propositions:
Not or Negation of a Proposition

Let p be a proposition. The negation of p, denoted by¬p (also denoted by p), is the statement
―It is not the case that p.‖ The proposition ¬p is read ―not p.‖ The truth value of the negation of p, ¬p, is the
opposite of the truth value of p.

Examples:

1. Find the negation of the proposition


―Michael‘s PC runs Linux‖ and express this in simple English.
Solution: The negation is
―It is not the case that Michael‘s PC runs Linux.‖
This negation can be more simply expressed as
―Michael‘s PC does not run Linux.‖

2. Find the negation of the following proposition

3. Write the negation of :

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
7 DISCRETE STRUCTURES

Truth Table of NOT

the truth table for the negation of a proposition p. This table has a row for each of
the two possible truth values of a proposition p. Each row shows the truth value of
¬p corresponding to the truth value of p for this row.
The negation of a proposition can also be considered the result of the operation of
the negation operator on a proposition. The negation operator constructs a new
proposition from a single existing proposition.We will now introduce the logical
operators that are used to form new propositions from two or more existing
propositions. These logical operators are also called
connectives.

Conjunction (AND):
Let p and q be propositions. The conjunction of p and q, denoted by p ∧ q, is the proposition
―p and q.‖ The conjunction p ∧ q is true when both p and q are true and is false otherwise.

Examples:

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
8 DISCRETE STRUCTURES

2. Find the conjunction of the propositions p and q where p is the proposition ―Rebecca‘s PC has
more than 16 GB free hard disk space‖ and q is the proposition ―The processor in Rebecca‘s
PC runs faster than 1 GHz.‖
Solution: The conjunction of these propositions, p ∧ q, is the proposition ―Rebecca‘s PC has
more than 16 GB free hard disk space, and the processor in Rebecca‘s PC runs faster than 1
GHz.‖ This conjunction can be expressed more simply as ―Rebecca‘s PC has more than 16 GB
free hard disk space, and its processor runs faster than 1 GHz.‖ For this conjunction to be true,
both conditions given must be true. It is false, when one or both of these conditions are false.

Truth Table of AND

Disjunction (OR)
Let p and q be propositions. The disjunction of p and q, denoted by p ∨ q, is the proposition
―p or q.‖ The disjunction p ∨ q is false when both p and q are false and is true otherwise.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
9 DISCRETE STRUCTURES

Truth Table of OR

Exclusive OR
Let p and q be propositions. The exclusive or of p and q, denoted by p ⊕ q, is the proposition
that is true when exactly one of p and q is true and is false otherwise.

Example:

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
10 DISCRETE STRUCTURES

Difference between OR and Exclusive OR

The use of the connective or in a disjunction corresponds to one of the two ways the word
or is used in English, namely, as an inclusive or. A disjunction is true when at least one of
the two propositions is true. For instance, the inclusive or is being used in the statement
―Students who have taken calculus or computer science can take this class.‖
Here, we mean that students who have taken both calculus and computer science can take the
class, as well as the students who have taken only one of the two subjects. On the other hand,
we are using the exclusive or when we say ―Students who have taken calculus or computer
science, but not both, can enroll in this class.‖

Here, we mean that students who have taken both calculus and a computer science course
cannot take the class. Only those who have taken exactly one of the two courses can take the
class. Similarly, when a menu at a restaurant states, ―Soup or salad comes with an entrée,‖
the restaurant almost always means that customers can have either soup or salad, but not
both.
Hence, this is an exclusive, rather than an inclusive, or.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
11 DISCRETE STRUCTURES

Conditional Statement or Implication

Let p and q be propositions. The conditional statement p → q is the proposition ―if p, then
q.‖ The conditional statement p → q is false when p is true and q is false, and true otherwise.
In the conditional statement p → q, p is called the hypothesis (or antecedent or premise)
and q is called the conclusion (or consequence).
Because conditional statements play such an essential role in mathematical reasoning, a
variety of terminology is used to express p → q. You will encounter most if not all of the
following ways to express this conditional statement:
―if p, then q‖ ―p implies q‖
―if p, q‖ ―p only if q‖
―p is sufficient for q‖ ―a sufficient condition for q is p‖
―q if p‖ ―q whenever p‖
―q when p‖ ―q is necessary for p‖
―a necessary condition for p is q‖ ―q follows from p‖

A useful way to understand the truth value of a conditional statement is to think of an


obligation or a contract. For example, the pledge many politicians make when running for office
is

Example 1:

―If I am elected, then I will lower taxes.‖

If the politician is elected, voters would expect this politician to lower taxes. Furthermore, if the
politician is not elected, then voters will not have any expectation that this person will lower
taxes, although the person may have sufficient influence to cause those in power to lower taxes.
It is only when the politician is elected but does not lower taxes that voters can say that the
politician has broken the campaign pledge. This last scenario corresponds to the case when p
is true but q is false in p → q.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
12 DISCRETE STRUCTURES

Example 2

Let p be the statement ―Maria learns discrete mathematics‖ and q the statement ―Maria will
find a good job.‖ Express the statement p → q as a statement in English.
Solution: From the definition of conditional statements, we see that when p is the statement
―Maria learns discrete mathematics‖ and q is the statement ―Maria will find a good job,‖ p → q
represents the statement
―If Maria learns discrete mathematics, then she will find a good job.‖
There are many other ways to express this conditional statement in English. Among the most
natural of these are:
―Maria will find a good job when she learns discrete mathematics.‖
―For Maria to get a good job, it is sufficient for her to learn discrete mathematics.‖
and
―Maria will find a good job unless she does not learn discrete mathematics.‖

Note that the way we have defined conditional statements is more general than the meaning
attached to such statements in the English language. For instance, the conditional statement in
Example 7 and the statement
―If it is sunny, then we will go to the beach.‖
are statements used in normal language where there is a relationship between the hypothesis
and the conclusion. Further, the first of these statements is true unless Maria learns discrete
mathematics, but she does not get a good job, and the second is true unless it is indeed sunny,
but we do not go to the beach. On the other hand, the statement ―If Juan has a smartphone, then 2 + 3 = 5‖
is true from the definition of a conditional statement, because its conclusion is true. (The truth
value of the hypothesis does not matter then.) The conditional statement
―If Juan has a smartphone, then 2 + 3 = 6‖
is true if Juan does not have a smartphone, even though 2 + 3 = 6 is false. We would not use
these last two conditional statements in natural language (except perhaps in sarcasm), because
there is no relationship between the hypothesis and the conclusion in either statement. In mathematical
reasoning, we consider conditional statements of a more general sort than we use in
English. The mathematical concept of a conditional statement is independent of a cause-andeffect
relationship between hypothesis and conclusion. Our definition of a conditional statement
specifies its truth values; it is not based on English usage. Propositional language is an artificial
language; we only parallel English usage to make it easy to use and remember.
The if-then construction used in many programming languages is different from that used
in logic. Most programming languages contain statements such as if p then S, where p is a
proposition and S is a program segment (one or more statements to be executed).When execution
of a program encounters such a statement, S is executed if p is true, but S is not executed if p
is false, as illustrated in Example 3.

What is the value of the variable x after the statement


if 2 + 2 = 4 then x := x + 1
if x = 0 before this statement is encountered? (The symbol := stands for assignment. The
statement x := x + 1 means the assignment of the value of x + 1 to x.)
Solution: Because 2 + 2 = 4 is true, the assignment statement x := x + 1 is executed. Hence,
x has the value 0 + 1 = 1 after this statement is encountered.

BICONDITIONALS We now introduce another way to combine propositions that expresses


that two propositions have the same truth value.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
13 DISCRETE STRUCTURES

Let p and q be propositions. The biconditional statement p ↔ q is the proposition ―p if


and only if q.‖ The biconditional statement p ↔ q is true when p and q have the same truth
values, and is false otherwise. Biconditional statements are also called bi-implications.

The truth table for p ↔ q is shown in the following table. Note that the statement p ↔ q is true when both
the conditional statements p → q and q → p are true and is false otherwise. That is why we use the words ―if
and only if‖ to express this logical connective and why it is symbolically written by combining the
symbols→and←. There are some other common ways to express p ↔ q:
―p is necessary and sufficient for q‖
―if p then q, and conversely‖
―p iff q.‖
The last way of expressing the biconditional statement p ↔ q uses the abbreviation ―iff‖ for
―if and only if.‖ Note that p ↔ q has exactly the same truth value as (p → q) ∧ (q → p).

EXAMPLE: Let p be the statement ―You can take the flight,‖ and let q be the statement ―You buy a ticket.‖
Then p ↔ q is the statement
―You can take the flight if and only if you buy a ticket.‖
This statement is true if p and q are either both true or both false, that is, if you buy a ticket and
can take the flight or if you do not buy a ticket and you cannot take the flight. It is false when
p and q have opposite truth values, that is, when you do not buy a ticket, but you can take the
flight (such as when you get a free trip) and when you buy a ticket but you cannot take the flight
(such as when the airline bumps you).

CONVERSE, CONTRAPOSITIVE, AND INVERSE: We can form some new conditional


statements starting with a conditional statement p → q. In particular, there are three related
conditional statements that occur so often that they have special names. The proposition q → p
is called the converse of p → q. The contrapositive of p → q is the proposition ¬q →¬p.
The proposition ¬p →¬q is called the inverse of p → q. We will see that of these three
conditional statements formed from p → q, only the contrapositive always has the same truth
value as p → q.
We first show that the contrapositive, ¬q →¬p, of a conditional statement p → q always
has the same truth value as p → q. To see this, note that the contrapositive is false only when
¬p is false and ¬q is true, that is, only when p is true and q is false. We now show that neither

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
14 DISCRETE STRUCTURES

the converse, q → p, nor the inverse, ¬p →¬q, has the same truth value as p → q for all
possible truth values of p and q. Note that when p is true and q is false, the original conditional
statement is false, but the converse and the inverse are both true.

When two compound propositions always have the same truth value we call them equivalent,
so that a conditional statement and its contrapositive are equivalent. The converse and
the inverse of a conditional statement are also equivalent, as the reader can verify, but neither is
equivalent to the original conditional statement. (We will study equivalent propositions in Section
1.3.) Take note that one of the most common logical errors is to assume that the converse
or the inverse of a conditional statement is equivalent to this conditional statement.
We illustrate the use of conditional statements in the following example

EXAMPLE 9 What are the contrapositive, the converse, and the inverse of the conditional statement
―The home team wins whenever it is raining?‖
Solution: Because ―q whenever p‖ is one of the ways to express the conditional statement
p → q, the original statement can be rewritten as
―If it is raining, then the home team wins.‖
Consequently, the contrapositive of this conditional statement is
―If the home team does not win, then it is not raining.‖
The converse is
―If the home team wins, then it is raining.‖
The inverse is
―If it is not raining, then the home team does not win.‖
Only the contrapositive is equivalent to the original statement.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
15 DISCRETE STRUCTURES

Precedence of Logical Operators

For instance, (p ∨ q) ∧ (¬r) is the conjunction


of p ∨ q and ¬r. However, to reduce the number of parentheses, we specify that the negation
operator is applied before all other logical operators. This means that ¬p ∧ q is the conjunction
of¬p and q, namely, (¬p) ∧ q, not the negation of the conjunction ofp and q, namely¬(p ∧ q).
Another general rule of precedence is that the conjunction operator takes precedence over
the disjunction operator, so that p ∧ q ∨ r means (p ∧ q) ∨ r rather than p ∧ (q ∨ r). Because
this rule may be difficult to remember, we will continue to use parentheses so that the order of
the disjunction and conjunction operators is clear.

Finally, it is an accepted rule that the conditional and biconditional operators → and ↔
have lower precedence than the conjunction and disjunction operators, ∧ and ∨. Consequently,
p ∨ q → r is the same as (p ∨ q) → r. We will use parentheses when the order of the conditional
operator and biconditional operator is at issue, although the conditional operator has
precedence over the biconditional operator. Table 8 displays the precedence levels of the logical
operators, ¬, ∧, ∨,→, and↔.

Truth Tables of Compound Propositions


EXAMPLE: Construct the truth table of the compound proposition
(p ∨¬q) → (p ∧ q).

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
16 DISCRETE STRUCTURES

Logic and Bit Operations


Computers represent information using bits.A bit is a symbol with two possible values, namely,
0 (zero) and 1 (one). This meaning of the word bit comes from binary digit, because zeros and
ones are the digits used in binary representations of numbers. The well-known statistician John
Tukey introduced this terminology in 1946.A bit can be used to represent a truth value, because
there are two truth values, namely, true and false. As is customarily done, we will use a 1 bit to
represent true and a 0 bit to represent false. That is, 1 represents T (true), 0 represents F (false).A
variable is called a Boolean variable if its value is either true or false. Consequently, a Boolean
variable can be represented using a bit.

Computer bit operations correspond to the logical connectives. By replacing true by a one
and false by a zero in the truth tables for the operators ∧, ∨, and ⊕, the tables shown in Table 9
for the corresponding bit operations are obtained.We will also use the notation OR, AND, and
XOR for the operators ∨,∧, and ⊕, as is done in various programming languages.

Bit String
A bit string is a sequence of zero or more bits. The length of this string is the number of bits in the string.
EXAMPLE: 101010011 is a bit string of length nine.

Solution: The bitwise OR, bitwise AND, and bitwise XOR of these strings are obtained by taking

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
17 DISCRETE STRUCTURES

the OR, AND, and XOR of the corresponding bits, respectively. This gives us

01 1011 0110
11 0001 1101
-----------------
11 1011 1111 bitwise OR
01 0001 0100 bitwise AND
10 1010 1011 bitwise XOR

Assignment No. 1

Applications of Propositional Logic

Logic has many important applications to mathematics, computer science, and numerous other
disciplines. Statements in mathematics and the sciences and in natural language often are imprecise
or ambiguous. To make such statements precise, they can be translated into the language
of logic. For example, logic is used in the specification of software and hardware, because these
specifications need to be precise before development begins. Furthermore, propositional logic
and its rules can be used to design computer circuits, to construct computer programs, to verify
the correctness of programs, and to build expert systems. Logic can be used to analyze and
solve many familiar puzzles. Software systems based on the rules of logic have been developed
for constructing some, but not all, types of proofs automatically.We will discuss some of these
applications of propositional logic in this section.

 Translating English Sentences


 System Specifications
 Boolean Searches
 Logic Puzzles
 Logic Circuits
Propositional Equivalences:
An important type of step used in a mathematical argument is the replacement of a statement with another
statement with the same truth value. Because of this, methods that produce propositions with the same truth
value as a given compound proposition are used extensively in the construction of mathematical arguments.
Note that we will use the term ―compound proposition‖ to refer to an expression formed from propositional
variables using logical operators, such as p ∧ q.
We begin our discussion with a classification of compound propositions according to their
possible truth values.

A compound proposition that is always true, no matter what the truth values of the propositional variables that
occur 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 nor a contradiction is called a contingency.
Prepared By: Muhammad Imran
Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
18 DISCRETE STRUCTURES

We can construct examples of tautologies and contradictions using just one propositional variable.
Example: Consider the truth tables of p ∨¬p and p ∧¬p, shown in Table 1. Because p ∨¬p is always true, it
is a tautology. Because p ∧¬p is always false, it is a contradiction.

Example − Prove [(A → B)  A] → B is a tautology


The truth table is as follows –

Example − Prove (A VB)  [(¬A)  (¬B)] is a contradiction


Solution:

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
19 DISCRETE STRUCTURES

Example − Prove (A  B)  (¬A) a contingency


Solution:

Logical Equivalences

Remark: The symbol ≡ is not a logical connective, and p ≡ q is not a compound proposition
but rather is the statement that p ↔ q is a tautology. The symbol⇔is sometimes used instead
of ≡ to denote logical equivalence.

EXAMPLE 1: Show that ¬(p ∨ q) and ¬p ∧¬q are logically equivalent.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
20 DISCRETE STRUCTURES

EXAMPLE 2: Show that p → q and ¬p ∨ q are logically equivalent.

EXAMPLE 4: Show that p ∨ (q ∧ r) and (p ∨ q) ∧ (p ∨ r) are logically equivalent. This is the distributive
law of disjunction over conjunction.

Laws of Logic

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
21 DISCRETE STRUCTURES

We also display some useful equivalences for compound propositions involving conditional
statements and biconditional statements in Tables 7 and 8, respectively.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
22 DISCRETE STRUCTURES

Sybolically De Morgan‘s Laws can be written as:

Applying Demorgan’s Law


Prepared By: Muhammad Imran
Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
23 DISCRETE STRUCTURES

Solution:

1. P: John is six feet tall


q: He weights atleast 200 pounds
¬(p ∧ q)= ¬p ∨¬q

2. p: The bus was late


q: Tom‘s watch was slow
¬(p ∨ q) = ¬p ∧¬q

Constructing New Logical Equivalences:

The logical equivalences in Table 6, as well as any others that have been established (such as
those shown in Tables 7 and 8), can be used to construct additional logical equivalences. The
reason for this is that a proposition in a compound proposition can be replaced by a compound
proposition that is logically equivalent to it without changing the truth value of the original
compound proposition.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
24 DISCRETE STRUCTURES

Show that ¬(p → q) and p ∧¬q are logically equivalent.


Solution: We could use a truth table to show that these compound propositions are equivalent (similar to what
we did in Example 4). Indeed, it would not be hard to do so. However, we want to illustrate how to use logical
identities that we already know to establish new logical identities, something that is of practical importance for
establishing equivalences of compound propositions with a large number of variables. So, we will establish
this equivalence by developing a series of logical equivalences, using one of the equivalences in Table 6 at a
time, starting with ¬(p → q)and ending with p ∧¬q.We have the following equivalences.

Example : Show that ¬(p ∨ (¬p ∧ q)) and ¬p ∧¬q are logically equivalent by developing a series of
logical equivalences.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
25 DISCRETE STRUCTURES

Solution:We will use one of the equivalences in Table 6 at a time, starting with¬(p ∨ (¬p ∧ q))
and ending with ¬p ∧¬q. (Note: we could also easily establish this equivalence using a truth
table.)We have the following equivalences.

Example:

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
26 DISCRETE STRUCTURES

By using Rules of Logic

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
27 DISCRETE STRUCTURES

Basic Logic Gates

Examples of Constructing Circuits

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
28 DISCRETE STRUCTURES

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
29 DISCRETE STRUCTURES

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
30 DISCRETE STRUCTURES

Answer:
Do yourself

Question: Construct a combinatorial circuit using inverters, OR gates, and AND gates that
produces the output (p ∧¬r) ∨ (¬q ∧ r) from input bits p, q, and r.
Solution:

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
31 DISCRETE STRUCTURES

Question: Construct a combinatorial circuit using inverters, OR gates, and AND gates that produces the output
((¬p ∨¬r)∧¬q) ∨ (¬p ∧ (q ∨ r)) from input bits p, q, and r.

Solution:

Equivalent Circuits

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
32 DISCRETE STRUCTURES

In the above example we have constructed the circuit from boolean expression. We have
already seen that we can simplify the boolean expression by using different laws of logic.
E.g Identity Law, Idempotent law etc.

So in the above example both the truth tables will be same. Hence if truth tables are same
the both circuits will also be equivalent after simplification.

Example

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
33 DISCRETE STRUCTURES

The Boolean expression of (a) is:

And the boolean expression for (b) is:

To show that both the circuits are equivalent we can use truth table or laws of logic.
Now we will use laws of logic to show that both are equivalent.

Hece proved both circuits are equivalent

NAND and NOR Gate

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
34 DISCRETE STRUCTURES

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
35 DISCRETE STRUCTURES

Rewriting Expressions by using Sheffer Stroke

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
36 DISCRETE STRUCTURES

Predicates and Quantifiers


Propositional logic, studied earlier, 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,‖

whereMATH3 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. We will
see how predicate logic can be used to express the meaning of a wide range of statements in
mathematics and computer science in ways that permit us to reason and explore relationships
between objects. To understand predicate logic, we first need to introduce the concept of a
predicate. Afterward, we will introduce the notion of quantifiers, which enable us to reason with
statements that assert that a certain property holds for all objects of a certain type and with
statements that assert the existence of an object with a particular property.

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(property of a subject or Expression that
contains variables), ―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),

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
37 DISCRETE STRUCTURES

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. Consider
Examples 1 and 2. A Predicate P(x) is a sentence that contains a finite number of variables
and becomes a proposition when specific values are substituted for the variable

We can also have statements that involve more than one variable. For instance, consider the
statement ―x = y + 3.‖ We can denote this statement by Q(x, y), where x and y are variables
and Q is the predicate. When values are assigned to the variables x and y, the statement Q(x, y)
has a truth value.

Similarly,we can letR(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.

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
38 DISCRETE STRUCTURES

In general, a statement involving the n variables x1, x2, . . . , xn can be denoted by


P(x1, x2, . . . , xn). A statement of the form P(x1, x2, . . . , xn) is the value of the
propositional function P at then-tuple (x1, x2, . . . , xn), and P is also called an n-place
predicate or a n-ary predicate.
Propositional functions occur in computer programs, as Example 6 demonstrates.

PRECONDITIONS AND POSTCONDITIONS Predicates are also used to establish the


correctness of computer programs, that is, to show that computer programs always produce
the desired output when given valid input. (Note that unless the correctness of a computer
program is established, no amount of testing can show that it produces the desired output for
all input values, unless every input value is tested.) 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. As Example 7 illustrates, we use predicates to
describe both preconditions and postconditions

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
39 DISCRETE STRUCTURES

Quantifiers
Quantifiers are the words that refer to quantities such as all, some, many, none, and few
are used in quantifications. 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 expresses the extent to which a predicate is
true over a range of elements. We will focus on two types of quantification here:
universal quantification, which tells us that a predicate is true for every element under
consideration, and existential quantification.

THE UNIVERSAL QUANTIFIER

Example:
―All students are hardworking‖
Let P(x) denote ―X is hardworking‖
Then the above statement can be written as:

∀xP(x)

Example1: 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?

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
40 DISCRETE STRUCTURES

Example 2 : Let Q(x) be the statement ―x < 2.‖ What is the truth value of the
quantification ∀xQ(x), where the domain consists of all real numbers?

Solution: 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 ∀xQ(x). Thus
∀xQ(x)
is false.

Example 3: Suppose that P(x) is ―x2 > 0.‖ To show that the statement ∀xP(x) is false
where the universe of discourse consists of all integers, we give a counterexample. We
see that x = 0 is a counterexample because x2 = 0 when x = 0, so that x2 is not greater than
0 when x = 0.

Example 4: 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.

THE EXISTENTIAL QUANTIFIER

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
41 DISCRETE STRUCTURES

A domain must always be specified when a statement ∃xP(x) is used. Furthermore, the
meaning of ∃xP(x) changes when the domain changes. Without specifying the domain,
the statement ∃xP(x) has no meaning.
Besides the phrase “there exists,” we can also express existential quantification in many
other ways, such as by using the words “for some,” “for at least one,” or “there is.”
The existential quantification ∃xP(x) is read as:
―There is an x such that P(x),‖
―There is at least one x such that P(x),‖
or
―For some xP(x).‖

Example 1: Let P(x) denote the statement ―x > 3.‖ What is the truth value of the
quantification ∃xP(x),
where the domain consists of all real numbers?
Solution: Because ―x > 3‖ is sometimes true—for instance, when x = 4—the existential
quantification of P(x), which is ∃xP(x), is true.
Observe that the statement ∃xP(x) is false if and only if there is no element x in the
domain for which P(x) is true.

Example 2: Let Q(x) denote the statement ―x = x + 1.‖What is the truth value of the
quantification ∃xQ(x), where the domain consists of all real numbers?
Solution: Because Q(x) is false for every real number x, the existential quantification of
Q(x), which is ∃xQ(x), is false.

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

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
42 DISCRETE STRUCTURES

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
43 DISCRETE STRUCTURES

Negating Quantified Expressions


We will often want to consider the negation of a quantified expression. For instance,
consider the negation of the statement
―Every student in your class has taken a course in calculus.‖
This statement is a universal quantification, namely,
∀xP(x), where P(x) is the statement ―x has taken a course in calculus‖ and the domain
consists of the students in your class. The negation of this statement is
―It is not the case that every student in your class has taken a course in calculus.‖ This is
equivalent to ―There is a student in your class who has not taken a course in calculus.‖
And this is simply the existential quantification of the
negation of the original propositional function, namely,
∃x ¬P(x).
This example illustrates the following logical equivalence:
¬∀xP(x) ≡ ∃x ¬P(x).
To show that ¬∀xP(x) and ∃xP(x) are logically equivalent no matter what the
propositional function P(x) is and what the domain is, first note that ¬∀xP(x) is true if
and only if ∀xP(x) is false. Next, note that ∀xP(x) is false if and only if there is an

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
44 DISCRETE STRUCTURES

element x in the domain for which P(x) is false. This holds if and only if there is an
element x in the domain for which ¬P(x) is true.
Finally, note that there is an element x in the domain for which ¬P(x) is true if and only
if ∃x ¬P(x) is true. Putting these steps together, we can conclude that ¬∀xP(x) is true if
and only if ∃x ¬P(x) is true. It follows that ¬∀xP(x) and ∃x ¬P(x) are logically
equivalent.
Suppose we wish to negate an existential quantification. For instance, consider the
proposition
―There is a student in this class who has taken a course in calculus.‖ This is the existential
Quantification
∃xQ(x),
where Q(x) is the statement ―x has taken a course in calculus.‖ The negation of this
statement
is the proposition ―It is not the case that there is a student in this class who has taken a
course in calculus.‖ This is equivalent to ―Every student in this class has not taken
calculus,‖ which is just the universal quantification of the negation of the original
propositional function, or, phrased in the language of quantifiers,
∀x ¬Q(x).
This example illustrates the equivalence

¬∃xQ(x) ≡ ∀x ¬Q(x).
Example: What are the negations of the statements ∀x(x2 > x) and ∃x(x2 = 2)?
Solution: The negation of ∀x(x2 > x) is the statement ¬∀x(x2 > x), which is equivalent
to ∃x¬(x2 > x). This can be rewritten as ∃x(x2 ≤ x). The negation of ∃x(x2 = 2) is the
statement ¬∃x(x2 = 2), which is equivalent to ∀x¬(x2 = 2). This can be rewritten as
∀x(x2 _= 2). The truth values of these statements depend on the domain.

Rules of Inference for Propositional Logic

We can always use a truth table to show that an argument form is valid.We do this by
showing that whenever the premises are true, the conclusion must also be true. However,
this can be a tedious approach. For example, when an argument form involves 10
different propositional variables, to use a truth table to show this argument form is valid
requires 210 = 1024 different rows. Fortunately, we do not have to resort to truth tables.
Prepared By: Muhammad Imran
Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
45 DISCRETE STRUCTURES

Instead, we can first establish the validity of some relatively simple argument forms,
called rules of inference. These rules of inference can be used as building blocks to
construct more complicated valid argument forms.
We will now introduce the most important rules of inference in propositional logic.

Argument
An argument is a sequence of statements. All the statements are called
Premises or assumptions or hypothesis. The final statement is called conclusion. The
symbol read as therefore and is normally placed just before the conclusion.

Valid Arguments

Identifying the Valid Arguments

Example

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.
46 DISCRETE STRUCTURES

Invalid Arguments

Prepared By: Muhammad Imran


Assistant Prof. of Computer Science, Govt. Millat Degree College, Multan.

You might also like