DM Lecture 5

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 45

Discrete Structures

Lecture 5
Applications of Logic

2
Todays Lecture Outline
• Basics of Boolean Algebra
• Decimal and Binary numbers
• Predicates & Set Notation

• Universal and Existential Statement


• Translating b/w formal and informal language
• Universal conditional Statements
• Equivalent Form of Universal and Existential statements

• Implicit Qualification
• Negations of Universal and Existential statements
Equivalent Circuits
Following is the circuit representations of the statement
[(P∧ ∼Q) ∨ (P ∧ Q)] ∧ Q
Equivalent Circuits

[(P ∧ ∼Q) ∨ (P ∧ Q)] ∧ Q


≡ (P ∧ (∼Q ∨ Q)) ∧ Q ; by the distributive law
≡ (P ∧ (Q ∨ ∼Q)) ∧ Q ; by the commutative law for

≡ (P ∧ t) ∧ Q ; by the negation law
≡P∧Q ; by the identity law.
Equivalent Circuits
Thus the two circuits are logically equivalent.
Equivalent Circuits
Find the Boolean expressions for the circuits and show
that they are logically equivalent
Equivalent Circuits
Find the Boolean expressions for the circuits and show
that they are logically equivalent
NAND and NOR Gates
Another way to simplify a circuit is to find an equivalent circuit
that uses the least number of different kinds of logic gates.
Two gates not previously introduced are useful for this: NAND-
gate and NOR-gate.
A NAND-gate is a single gate that acts like an AND-gate
followed by a NOT-gate.
A NOR-gate acts like an OR-gate followed by a NOT-gate.
Thus the output signal of a NAND-gate is 0 when, and only
when, both input signals are 1, and the output signal for a
NOR-gate is 1 when, and only when, both input signals are 0.
The logical symbols corresponding to these gates are | (for
NAND) and ↓ (for NOR), where | is called a Sheffer stroke
and ↓ is called a Peirce arrow. Thus

P | Q ≡ ∼(P ∧ Q) and P ↓ Q ≡ ∼(P ∨ Q).


NAND and NOR Gates
NAND and NOR Gates
It can be shown that any Boolean expression is
equivalent to one written entirely with Sheffer strokes or
entirely with Peirce arrows. Thus any digital logic circuit
is equivalent to one that uses only NAND-gates or only
NOR-gates.
Rewriting Expressions Using the Sheffer Stroke

Use the definition of Sheffer stroke to show that


a. ∼P ≡ P | P b. P ∨ Q ≡ (P | P) | (Q | Q).
Rewriting Expressions Using the Peirce Arrow

Show that the following logical equivalences hold for the


Peirce arrow ↓, where P ↓ Q ≡ ∼(P ∨ Q).

a. ∼P ≡ P ↓ P
b. P ∨ Q ≡ (P ↓ Q) ↓ (P ↓ Q)
c. P ∧ Q ≡ (P ↓ P) ↓ (Q ↓ Q)

b. (P ↓ Q) ↓ (P ↓ Q)

≡ ∼(P ↓ Q) by part (a)

≡ ∼[∼(P ∨ Q)] by definition of ↓


≡P∨Q by the double negative law
Boolean Algebra

Decimal representations

6152 = 6*1000 + 1*100 + 5*10 + 2*1

= 6*103 + 1*102 + 5*101 + 2*100.

More generally, decimal notation is based on the fact that any positive
integer can be written uniquely as a sum of products of the form

d ·10n
where each n is a nonnegative integer and each d is one of the decimal
digits 0, 1, 2, 3, 4, 5, 6, 7, 8, or 9. The word decimal comes from the Latin
root deci, meaning “ten.”
Boolean Algebra

Converting decimal to binary representations

27 = 16 + 8 + 2 + 1
= 1·24 + 1·23 + 0·22 + 1·21 + 1·20.
Boolean Algebra
Any integer can be represented uniquely as a sum of products of the form
d ·2n
where each n is an integer and each d is one of the binary digits (or bits) 0
or 1.
Converting binary to decimal
Represent 110101 in decimal notation.
Addition in Binary Notation
Add 11012 and 1112 using binary notation.
Solution: Because 210 = 102 and 110 = 12, the translation of 110 +
110 = 210 to binary notation is

It follows that adding two 1’s together results in a carry of 1 when


binary notation is used. Adding three 1’s together also results in a
carry of 1 since 310 = 112 (“one one base two”).

Thus the addition can be performed as follows:


Predicates and Quantified statements I
Predicates
A predicate is a sentence which contains finite number of
variables and becomes a statement when specific values
are substituted for the variables.

The domain of a predicate variable is the set of all values that


may be substituted in place of the variable

Truth Set
If P(x) is a predicate and x has domain D, the truth set of
P(x) is the set of all elements of D that make P(x) true
when substituted for x. The truth set of P(x) is denoted by

read as “the set of all x in D such that P(x)”.


Notation
For any two predicates P(x) and Q(x), the notation
means that every element in the truth set of
P(x) is in the truth set of Q(x). The notation
means that P and Q have identical truth sets.

Consider the predicate:

The truth set of the above predicate is


Cont…

Example
Let P(x) = x is a factor of 8, Q(x)= x is a factor of 4
and R(x)= x < 5 and . The domain of x is
assumed to be . Use symbols , to indicate
true relationships among P(x), Q(x) and R(x).

a. The truth set of P(x) is {1,2,4,8}, Q(x) is {1,2,4}.


Since every element in the truth set of Q(x) is in the
truth set of P(x), So

b. The truth Set of R(x) is {1,2,4}, which is identical to


the truth set of Q(x). Hence .
Cont…
Let Q(x, y) be the statement
x+y=x−y
where the domain for x and y is the set of all real numbers.
Determine the truth value of:
(a) Q(5,−2).
(b) Q(4.7, 0).
(c) Determine the set of all pairs of numbers, x and y, such that
Q(x, y) is true.
Solution:
(a) Q(5,−2) says that 5 + (−2) = 5 − (−2), or 3= 7, which is false.
(b) Q(4.7, 0) says that 4.7+ 0 = 4.7 − 0, which is true.
(c) x + y = x − y if and only if x + 2y = x, which is true if and only if
y = 0. Therefore, x can be any real number and y must be zero.
Universal and Existential Statements

Let Q(x) be a predicate and D the domain of x. A


universal statement is of the form “ ”. It is
true if and only if Q(x) is true for all x in D and it is
false if and only if Q(x) is false for at least one x in D. A
value for x for which Q(x) is false is called a
counterexample to the universal statement.

Example: Let D={1,2,3,4,5} and consider the


statement Show that this statement is
true.
Solution: Check that is true for each individual
x in D.
Cont…..
Hence is true.
The technique used in first statement while showing the
truthness of the universal statement is called method of
exhaustion.

Consider the statement Find the counter


example to show that this statement is not true.
Counter example . Take x=1/2, then x is in R and

Hence is false.
Existential Quantifier
Let Q(x) be a predicate and D the domain of
x. An existential statement is of the form.
such that
It is true if and only if Q(x) is true for at least
one x in D. It is false if and only if Q(x) is
false for all x in D.
The symbol denotes “there exist” and is
called the existential quantifier.
Truth and falsity of Existential statements
Suppose P(x) is the predicate “x < |x|.” Determine the
truth value of ∃ x s.t. P(x) where the domain for x is:
(a) the three numbers 1, 2, 3.
(b) the six numbers −2,−1, 0, 1, 2, 3.
Solution
(a) P(1), P(2), and P(3) are all false because in each
case x = |x|. Therefore, ∃ x such that P(x) is false for
this domain.
(b) If we begin checking the six values of x, we find
P(−2) is true. It states that −2 < |−2|. We need to check
no further; having one case that makes the predicate
true is enough to guarantee that ∃ x s.t. P(x) is true.
Truth and falsity of Existential statements

Consider the statement . Show


that this statement is true.
Sol: observe that . Thus is true for at
least one integer m . Hence is
true.

Let E={5,6,7,8,9,10} and consider the statement

Show that this statement is false.


Sol: the statement is not true for every value of
the E. Thus is false.
Translating from formal to informal language

Rewrite the following statements in a variety of


equivalent but more informal ways. Do not use the
symbol
a)
b)
c)
Solution: a) we can write the statement in many ways
like “ All real numbers have non negative squares”,
“No real number has a negative square”,
“ x has a non negative square, for each value of x”.
Cont….
b). Similarly we can translate the second statement in
these ways.
“ All real numbers have squares not equal to -1”,
“No real number have square equal to -1”.

c). “There is an integer whose square is equal to itself”,


“we can find at least one integer equal to its own
square”
Cont…
Write the following statement in English, using the
predicates
F(x): “x is a Freshman”
T (x, y): “x is taking y”
where x represents students and y represents courses:

∃x (F(x) ∧ T (x, Discrete Math))

Solution
The statement ∃ x (F(x)∧T (x, Discrete)) says that there
is a student x with two properties: x is a freshman and x
is taking Discrete. In English, “Some Freshman is taking
Discrete Math.”
Translating from informal Language to Formal language
“Every freshman at the College is taking MATH3901.”
Solution: There are various ways to answer this question,
depending on the domain.
• If we take as our domain all freshmen at the College
and use the predicate T (x) : “x is taking MATH3901”,

then the statement can be written as ∀x, T(x).


• We are making a conditional statement:
“If the student is a freshman, then the student is taking

MATH3901;”
∀x, (F(x) → T (x)).
Note that we cannot say ∀ x (F(x) ∧ T (x)), because this
says that every student is a freshman, which is not
Cont…..
“Every freshman at the College is taking some Computer
Science course.”

Sol: If we take as our domain for people all freshmen at


the College and our domain for courses, all Computer
Science courses.
Then we can use the predicate

T (x, y): “x is taking y”

The statement can be written as

∀x ∃y T(x, y).
Universal Conditional Statements
A reasonable argument can be made that the most
important form of statement in mathematics is the
universal conditional statement:
∀ x, if P(x) then Q(x)
Example: “Everyone who visited France stayed in
Paris.”
Sol: However, if we take all people as the universe ,
then we need to introduce the predicate F(x) for “x
visited France.” and P(x) is the predicate “x stayed in
Paris.” In this case, the proposition can be written as

∀ x, (F(x) → P(x)).
• We can write the following statements in a
variety of informal ways.
if then
Sol:
• if a real number is greater then 2, then the
square is greater than 4.
• Whenever a real number is greater then 2,
its square is greater than 4.
• The squares of real number, greater than 2,
are greater than 4.
Exercise
Rewrite the following statements in the form
∀ ,if then .

a) If a real number is an integer, then it is a rational


number.
b) All bytes have eight bits.
c) No fire trucks are green.

Sol: a).

b). ∀ x, if x is a byte, then x has eight bits.

c). ∀ x, if x is a fire truck, then x is not green.


Equivalent Forms of Universal and Existential statements

Observe that the two statements “∀ real


numbers x, if x is an integer then x is
rational” and “∀ integers x, x is rational”
mean the same thing.
In fact, a statement of the form
if P(x) then Q(x).
Can always be rewritten in the form

Can be rewritten as
∀x, if x is in D then Q(x).
Contd.
The following statements are equivalent
∀ polygons P, if P is square, then P is a rectangle.
And
∀ squares P, P is a rectangle

The existential statements

∃ x belongs to U such that P(x) and Q(x).


And
∃ x belongs to D such that Q(x)

Are also equivalent provided D is taken to consist of all elements in


U that make P(x) true.
Equivalence form for existential statement

The following statements are equivalent:


∃ a number n such that n is prime and n is even
And
∃ a prime number n such that n is even.
Implicit Quantifications
• Consider “ If a number is an integer, then it is a
rational number”
The clue to indicate its universal quantifications comes
from the presence of the indefinite article “a”.

Existential quantification can also be implicit.


for instance, “ the number 24 can be written as a sum of
two even integers”
“∃ even integers m and n such that 24=m + n.”
Negations of Quantified Statement
The negation of the statement of the form
∀ x in D, Q(x)
is logically equivalent to a statement of the
form
∃ x in D such that ~Q(x)
Symbolically:

Note: the negation of universal statement is


logically equivalent to existential statement.
Cont….
The negation of the statement of the form
∃ x in D such that Q(x)
is logically equivalent to a statement of the
form
∀ x in D, ~Q(x)
Symbolically:

Note: the negation of existential statement is


logically equivalent to universal statement.
Examples
Negate “Some integer x is positive and all integers
y are negative.”
Solution: Using all integers as the universe for x and y,
the statement is ∃ x s.t. (x > 0) ∧ ∀ y, (y < 0). The
negation is
~{∃x (x > 0) ∧ ∀ y (y < 0)}≡ ~∃x s.t. (x > 0) ∨ ~∀y, (y <
0): by De Morgan’s law
≡ ∀ x, ~(x > 0) ∨ ∃ y s.t. ~(y < 0) properties of negation
≡ ∀ x, (x ≤ 0) ∨ ∃ y s.t. (y ≥ 0).

Therefore, the negation is “Every integer x is non


positive or there is an integer y that is nonnegative.”
Cont….
Negate “There is a student who came late to class
and there is a student who is absent from class.”
Solution: In symbols, if L(x) : “x came late to class” and
A(x) : “x is absent from class,” this statement can be
written as ∃ x st L(x) ∧ ∃ y st A(y).
Note that we must use a second variable y. By one of
De Morgan’s laws the negation can be written as
~(∃ x st L(x)) ∨ ~(∃ y st A(x)) ≡ ∀x, ~L(x) ∨ ∀ y, ~A(x).
In English this is “No student came late to class or no
student is absent from class.”
Lecture Summary
• Basics of Boolean Algebra
• Decimal and Binary numbers
• Predicates & Set Notation

• Universal and Existential Statement


• Translating b/w formal and informal language
• Universal conditional Statements
• Equivalent Form of Universal and Existential statements

• Implicit Qualification
• Negations of Universal and Existential statements

You might also like