0% found this document useful (0 votes)
110 views112 pages

Thisyear PDF

This document provides a syllabus for a course on discrete structures. The syllabus outlines 6 units that will be covered: logic, set theory, functions, algebraic structures, elementary combinatorics, and number theory. It also lists the goals of the course, which are to teach mathematical reasoning, discrete structures, combinatorial analysis, and number theory and applications. Key concepts that will be covered include propositional logic, sets, relations, functions, groups, counting principles, and number theoretic topics like divisibility, modular arithmetic, primes, and greatest common divisors.

Uploaded by

egeun mankd
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)
110 views112 pages

Thisyear PDF

This document provides a syllabus for a course on discrete structures. The syllabus outlines 6 units that will be covered: logic, set theory, functions, algebraic structures, elementary combinatorics, and number theory. It also lists the goals of the course, which are to teach mathematical reasoning, discrete structures, combinatorial analysis, and number theory and applications. Key concepts that will be covered include propositional logic, sets, relations, functions, groups, counting principles, and number theoretic topics like divisibility, modular arithmetic, primes, and greatest common divisors.

Uploaded by

egeun mankd
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/ 112

Discrete Structures

DAY 1
Syllabus
Unit-1 Logic: Propositional logic and its applications; Propositional equivalences;
Predicates and Quantifiers; Rules of inference; Introduction to Proofs; Proof Methods;
Proof by Mathematical Induction (Weak and Strong).
Unit-2 Set theory: Sets, operations on sets, cardinality, inductive definition of sets and proof
by induction; Relations, representation of relations, properties of relations,
equivalence relations and partitions; Partial orderings; Posets; Well-ordered sets.
Unit-3 Functions: Mappings; Injection and Surjection; Composition of functions; Inverse
functions; Special functions; recursive function theory.
Unit-4 Algebraic Structures: Definition and elementary properties of groups; semigroups;
monoids; rings; fields, vector spaces; lattices and Boolean Algebra.
Unit-5 Elementary combinatorics: Basic Counting Principles; Permutations and
Combinations; Binomial Coefficients and Identities; Generalized Permutations and
Combinations; Sterling’s number of the second kind; Pigeon-hole Principle and its
application; Inclusion-Exclusion Principle and its application; Recurrence Relations;
Solving Linear Recurrence Relations; Generating Functions; Catalan Numbers;
Fibonacci numbers.
Unit-6 Number Theory: Divisibility and Modular Arithmetic; Integer Representations and
Algorithms; Prime numbers and related Theorems; Greatest Common Divisors;
Euclid’s Algorithm; Solving Congruence; Applications of Congruence, Fermat’s Little
Theorem,
1. K. H.The Chinese
Rosen Remainder
, Discrete Theorem;and
Mathematics Applications in Cryptography.
Applications, TMH
Goals of this Course
 Students should learn a particular set of mathematical facts and how to apply
them; more importantly, how to think logically and mathematically.
1. Mathematical Reasoning: understand mathematical reasoning in order to read,
comprehend, and construct mathematical arguments. Mathematical logic,
discussions of methods of proof.
2. Discrete Structures: Abstract mathematical structures used to represent discrete
objects and relationships between these objects. These discrete structures include
sets, permutations, relations, graphs, trees.
3. Combinatorial Analysis: Basic techniques of counting. Combinatorial analysis to solve
counting problems.
4. Number Theory and Applications:
Number Theory

 Divisibility and Modular Arithmetic

 Division
 If a and b are integers with a ≠ 0, we say that a divides b if there is an integer c
such that b = ac. When a divides b we say that a is a factor or divisor of b, and that
b is a multiple of a. The notation a | b denotes that a divides b. We write a ∤ b when
a does not divide b.
THEOREM 1
Let a, b, and c be integers, where a = 0. Then
(i ) if a | b and a | c, then a | (b + c);
(ii ) if a | b, then a | bc for all integers c;
(iii ) if a | b and b | c, then a | c.
 THEOREM 2
 THE DIVISION ALGORITHM Let a be an integer and d a positive integer. Then there are
unique integers q and r, with 0 ≤ r < d, such that a = dq + r.

 What are the quotient and remainder when −11 is divided by 3. Which one is correct?

−11 = 3(−3) − 2

−11 = 3(−4) + 1.
Modular Arithmetic
 In some situations we care only about the remainder of an integer when it is divided by some
specified positive integer.
Q. what time it will be (on a 12-hour clock) 50 hours from now (Assume 3:30 pm)

 If ‘a’ and ‘b’ are integers and ‘m’ is a positive integer, then ‘a’ is congruent to ‘b’ modulo ‘m’ if m
divides a − b. We use the notation a ≡ b (mod m) to indicate that a is congruent to b modulo m.
 If a and b are not congruent modulo m, we write a ≢ b (mod m).
THEOREM 3: Let ‘a’ and ‘b’ be integers, and let m be a positive integer.
Then a ≡ b (mod m) if and only if a mod m = b mod m.

Eg: 2 ≡ 9 (mod 7) 2 mod 7= 2 9 mod 7 =2

THEOREM 4: Let m be a positive integer. The integers ‘a’ and ‘b’ are congruent modulo
‘m’ if and only if there is an integer ‘k’ such that a = b + km.
Eg: 13 ≡ 3 (mod 5) 13 = 3 + 2 × 5, k = 2
2 ≡ 9 (mod 7) k=?

PROPERTIES
1. 𝑎 + 𝑏 𝑚𝑜𝑑 𝑛 = 𝑎 𝑚𝑜𝑑 𝑛 + 𝑏 𝑚𝑜𝑑 𝑛 𝑚𝑜𝑑 𝑛
2. 𝑎 − 𝑏 𝑚𝑜𝑑 𝑛 = 𝑎 𝑚𝑜𝑑 𝑛 − 𝑏 𝑚𝑜𝑑 𝑛 𝑚𝑜𝑑 𝑛
3. 𝑎 × 𝑏 𝑚𝑜𝑑 𝑛 = 𝑎 𝑚𝑜𝑑 𝑛 × 𝑏 𝑚𝑜𝑑 𝑛 𝑚𝑜𝑑 𝑛
 43 𝑚𝑜𝑑 11 : easy to compute as the values are small
 Modular Exponentiation
Find 𝑎𝑛 𝑚𝑜𝑑 𝑚 efficiently, where a, n, and m are large integers.
 ALGORITHM (Modular Exponentiation)
 a: integer, 𝑛 = (𝑏𝑘−1 𝑏𝑘−2 …𝑏1 𝑏0 )2 (binary representation), m: positive integers
 x := 1
 power := a mod m
 for i := 0 to k − 1
 if 𝑏𝑖 = 1
 then x := (x ・ power) mod m
 power := (power ・ power) mod m

 return x {x equals 𝑎𝑛 𝑚𝑜𝑑 𝑚 }

Q. Solve 2335 𝑚𝑜𝑑 19 = ?


43 𝑚𝑜𝑑 11
3=(11)2
𝒙 =1; power = 𝟒 𝒎𝒐𝒅 𝟏𝟏 = 𝟒

i=0 𝑏0 = 1 𝒙 = 𝟏. 𝟒𝐦𝐨𝐝𝟏𝟏 = 𝟒 𝒑𝒐𝒘𝒆𝒓 = 𝟒𝟐 𝒎𝒐𝒅 𝟏𝟏 = 𝟓


i=1 𝑏1 = 1 𝒙 = 𝟒. 𝟓 𝐦𝐨𝐝𝟏𝟏 = 𝟗

2335 𝑚𝑜𝑑 19
 2335 𝑚𝑜𝑑 19
35 = (100011)2
𝒙 =1; power = 𝟐𝟑 𝒎𝒐𝒅 𝟏𝟗 = 𝟒

𝒊=𝟎 𝑏0 = 1 𝒙 = 𝟏. 𝟒 𝐦𝐨𝐝 𝟏𝟗 = 𝟒 𝒑𝒐𝒘𝒆𝒓 = 𝟒𝟐 𝒎𝒐𝒅 𝟏𝟗 = 𝟏𝟔

𝒊=𝟏 𝑏1 = 1 𝒙 = 𝟒. 𝟏𝟔 𝐦𝐨𝐝 𝟏𝟗 = 7 𝒑𝒐𝒘𝒆𝒓 = 𝟏𝟔𝟐 𝒎𝒐𝒅 𝟏𝟗 = 𝟗

𝒊=𝟐 𝑏2 = 0 𝒙 = 𝟕 𝐦𝐨𝐝 𝟏𝟗 = 𝟕 𝒑𝒐𝒘𝒆𝒓 = 𝟗𝟐 𝒎𝒐𝒅 𝟏𝟗 = 𝟓

𝒊=𝟑 𝑏3 = 0 𝒙 = 𝟕 𝐦𝐨𝐝 𝟏𝟗 = 𝟕 𝒑𝒐𝒘𝒆𝒓 = 𝟓𝟐 𝒎𝒐𝒅 𝟏𝟗 = 𝟔

𝒊=𝟒 𝑏4 = 0 𝒙 = 𝟕 𝐦𝐨𝐝 𝟏𝟗 = 𝟕 𝒑𝒐𝒘𝒆𝒓 = 𝟔𝟐 𝒎𝒐𝒅 𝟏𝟗 = 𝟏𝟕

𝒊=𝟓 𝑏5 = 1 𝒙 = 𝟕. 𝟏𝟕 𝐦𝐨𝐝 𝟏𝟗 = 𝟓
Representations of Integers

THEOREM: Let b be an integer greater than 1. Then if n is a positive integer, it can be


expressed uniquely in the form
𝒏 = 𝒂𝒌 𝒃𝒌 + 𝒂𝒌−𝟏 𝒃𝒌−𝟏 + ⋯ + 𝒂𝟏 𝒃 + 𝒂𝟎
where k is a nonnegative integer, 𝒂𝟎 , 𝒂𝟏 ,…, 𝒂𝒌 are nonnegative integers less than b,
and 𝒂𝒌 ≠ 𝟎.

BINARY EXPANSIONS:
Q. What is the decimal expansion of the integer that has (10101110)2 as its binary
expansion?
Q. What is the decimal expansion of the number with hexadecimal expansion
(2𝐴𝐸0𝐶)16
Binary addition
1110 1011
+ 1011 +1101
11001 1111
0101
?
Binary multiplication
110
101
110
000x
110xx
11110
• Multiplicative inverse

In 𝑍𝑛 , two numbers ‘a’ and ‘b’ are multiplicative inverse of each other if
𝑎 × 𝑏 ≡ 1 𝑚𝑜𝑑 𝑛.
Eg If the modulus is 10, the multiplicative inverse of 3 is 7.
3 × 7 ≡ 1 𝑚𝑜𝑑 10.

Finding multiplicative inverse:


The extended Euclidean algorithm finds the multiplicative
inverses of b in 𝑍𝑛 where ‘n’ and ‘b’ are given and gcd (n, b) = 1
1
Q. Find the multiplicative inverse of 11 in 𝑍26 𝑥 ≡ 11 𝑚𝑜𝑑 26

First check, gcd(26, 11) = 1


𝒒 𝒓𝟏 𝒓𝟐 𝒓 = 𝒓𝟏 − 𝐪𝒓𝟐 𝒕𝟏 𝒕𝟐 𝒕 = 𝒕𝟏 − 𝒒𝒕𝟐
2 26 11 4 0 1 -2
2 11 4 3 1 -2 5
1 4 3 1 -2 5 -7
3 3 1 0 5 -7 26
1 0 -7 26
Stop when 𝒓𝟐 = 0
−7 𝑚𝑜𝑑 26 = 19
𝑥 = 19 [Check: 19 × 11 𝑚𝑜𝑑 26 = 209 𝑚𝑜𝑑 26 = 1]

Q. Find the multiplicative inverse of 23 in 𝑍100


−3
Q. 𝑥 ≡ 13 𝑚𝑜𝑑 7
Primes and Greatest Common Divisors
• Primes
• An integer p greater than 1 is called prime if the only positive factors of p are
1 and p. A positive integer that is greater than 1 and is not prime is called
composite.
• THE FUNDAMENTAL THEOREM OF ARITHMETIC: Every integer
greater than 1 can be written uniquely as a prime or as the product of
two or more primes where the prime factors are written in order of
non decreasing size.
• Eg: 100 = 2 × 2 × 5 × 5 = 22 52
999 = 33 37
• THEOREM
If n is a composite integer, then n has a prime divisor less than or equal
to √𝑛.
Eg: Check 71 is prime or not? Floor(√71) = 8
THEOREM
There are infinitely many primes.

(both the above theorem can be proved using Proofs by contradiction.


Proof will be shown when we study “Introduction to Proofs”)
Greatest Common Divisors
• Let a and b be integers, not both zero. The largest integer d such that
d | a and d | b is called the greatest common divisor of a and b. The
greatest common divisor of a and b is denoted by gcd(a, b).
• The integers a and b are relatively prime if their greatest common
divisor is 1.
• The integers 𝑎1 , 𝑎2 , … , 𝑎𝑛 are pairwise relatively prime if gcd(𝑎𝑖 ,
𝑎𝑗 ) = 1 whenever 1 ≤ 𝑖 < 𝑗 ≤ 𝑛.
Q. Determine whether the integers are pairwise relatively prime
i. 10, 17, and 21
ii. 10, 19, and 24
GDCs as Linear Combinations
• BÉZOUT’S THEOREM: If a and b are positive integers, then there exist
integers s and t such that gcd(a, b) = sa + tb (called Bézout’s identity).

• The value of s and t can be computed either using Euclidean Algorithm or


Extended Euclidean Algorithm.
• Euclidean Algorithm is based on two facts
• gcd 𝑎, 0 = 𝑎
• gcd 𝑎, 𝑏 = gcd 𝑏, 𝑟 , where 𝑟 is the remainder of dividing 𝑎 by 𝑏.
Eg: gcd 6, 4 = gcd 4, 2 = gcd 2, 0 =2

LEMMA: Let a = bq + r, where a, b, q, and r are integers. Then gcd(a, b) = gcd(b, r).
Q. Given 𝑎 = 252, 𝑏 = 198. Find ‘s’ and ‘t’ such that gcd 𝑎, 𝑏 = 𝑠 × 𝑎 + 𝑡 × 𝑏
using Euclidean Algorithm
252 = 1 × 198 + 54
198 = 3 × 54 + 36
54 = 1 × 36 + 18
36 = 2 × 18 + 0

Using the next-to-last division, we can express gcd(252, 198) = 18 as a linear


combination of 54 and 36.
18 = 54 − 1 × 36 ---(𝑖)
36 = 198 − 3 × 54 −−−(𝑖𝑖)
54 = 252 − 1 × 198 −−−(𝑖𝑖𝑖)

18 = 54 − 1 × 198 − 3 × 54 = 4 × 54 − 1 × 198
= 4 × 252 − 1 × 198 −1 × 198 = 4 × 252 − 5 × 198
18 = 4 × 252 + (−5) × 198
Q. Given 𝑎 = 252, 𝑏 = 198. Find ‘s’ and ‘t’ such that gcd 𝑎, 𝑏 = 𝑠 ×
𝑎 + 𝑡 × 𝑏 using extended Euclidean Algorithm

𝒒 𝒓𝟏 𝒓𝟐 𝒓 = 𝒓𝟏 − 𝐪𝒓𝟐 𝒔𝟏 𝒔𝟐 𝐬 = 𝒔𝟏 − 𝒒𝒔𝟐 𝒕𝟏 𝒕𝟐 𝒕 = 𝒕𝟏 − 𝒒𝒕𝟐


1 252 198 54 1 0 1 0 1 -1
3 198 54 36 0 1 -3 1 -1 4
1 54 36 18 1 -3 4 -1 4 -5
2 36 18 0 -3 4 -11 4 -5 14
18 0 4 -11 -5 14

Q. Given a=161 and b=28, find gcd(𝑎, 𝑏) and the value of s and t such
that gcd 𝑎, 𝑏 = 𝑠 × 𝑎 + 𝑡 × 𝑏
Linear Diophantine Equations
• Find integer values of 𝑥 and 𝑦 that satisfy 𝑎𝑥 + 𝑏𝑦 = 𝑐.
• This type of equation has either no solution or an infinite number of
solutions.
• Let 𝑑 = gcd(𝑎, 𝑏).
• If 𝑑 ∤ 𝑐, then the equations has no solution.
• If 𝑑|𝑐, then the equations have an infinite number of solutions. One of them is called
particular solutions and the rest general.
• Particular Solution
• If 𝑑|𝑐:
• Reduce the equations to 𝑎1 𝑥 + 𝑏1 𝑦 = 𝑐1 by dividing both sides by d.
• Solve for s and t in the relations 𝑎1 𝑠 + 𝑏1 𝑡 = 1 using extended Euclidian algorithm.
• Particular solutions: 𝑥0 = 𝑐1 𝑠 and 𝑦0 = 𝑐1 𝑡
• General solutions: 𝑥 = 𝑥0 + 𝑘𝑏1 and y = 𝑦0 − 𝑘𝑎1 , where k is an integer
Q. Find the particular and general solutions to the equations 21𝑥 + 14𝑦 = 35

𝑑 = gcd 21, 4 = 7.

Since 7|35, the equations has infinite solutions


3𝑥 + 2𝑦 = 5
Use extended Euclidean algorithm and find s and t such that 3𝑠 + 2𝑡 = 1
𝒒 𝒓𝟏 𝒓𝟐 𝒓 = 𝒓𝟏 − 𝐪𝒓𝟐 𝒔𝟏 𝒔𝟐 𝐬 = 𝒔𝟏 − 𝒒𝒔𝟐 𝒕𝟏 𝒕𝟐 𝒕 = 𝒕𝟏 − 𝒒𝒕𝟐
1 3 2 1 1 0 1 0 1 -1
2 2 1 0 0 1 -2 1 -1 3
1 0 1 -2 -1 3
𝑠 = 1 and 𝑡 = −1
Particular: 𝑥0 = 5 × 1 = 5 and 𝑦0 = 5 × −1 = −5
General: 𝑥 = 5 + 𝑘 × 2 and y = −5 − 𝑘 × 3, where 𝑘 is an integer
Euler’s Phi function ∅(𝑛)/Euler’s totient function

• Euler’s Phi function finds the number of integers that are both smaller than
‘n’ and relatively prime to ‘n’.
Some rules to find ∅(𝑛)
1. ∅ 1 = 0
2. ∅ 𝑝 = 𝑝 − 1 if p is a prime
3. ∅ 𝑚 × 𝑛 = ∅(𝑚) × ∅(𝑛), if m and n are relatively prime
4. ∅ 𝑝𝑒 = 𝑝𝑒 -𝑝𝑒−1 , if p is prime.
𝑒 𝑒 𝑒
If n can be factored as 𝑛 = 𝑝11 × 𝑝22 × ⋯ × 𝑝𝑘𝑘 ,combine third and forth rule
to find
𝑒1 𝑒1 −1 𝑒2 𝑒2 −1 𝑒𝑘 𝑒𝑘 −1
∅ 𝑛 =(𝑝1 − 𝑝1 ) × (𝑝2 − 𝑝2 ) × ⋯ × (𝑝𝑘 −𝑝𝑘 )
Q. What is the value of
i. ∅ 13 = 13 − 1 = 12
ii. ∅ 10 = ∅ 2 × ∅ 5 = 1 × 4 = 4
iii. ∅ 240 =?

Fermat’s Little Theorem


First theorem: If p is a prime and a is an integer such that p does not divide a,
then 𝑎𝑝−1 ≡ 1 𝑚𝑜𝑑 𝑝
Second theorem: If p is a prime and a is an integer,
then 𝑎𝑝 ≡ 𝑎 𝑚𝑜𝑑 𝑝
Q. Find
i. 610 𝑚𝑜𝑑 11
ii. 312 𝑚𝑜𝑑 11 = (3 × 311 ) 𝑚𝑜𝑑 11 = 3 𝑚𝑜𝑑 11 × 311 𝑚𝑜𝑑 11 𝑚𝑜𝑑 11
= 3 × 3 𝑚𝑜𝑑 11 = 9
iii. 728 𝑚𝑜𝑑 13 =?
Some multiplicative inverse can be solved using Fermat’s Little
Theorem if the modulus is prime. If p is the prime and a is an integer
such that 𝑝 ∤ 𝑎 then 𝑎−1 𝑚𝑜𝑑 𝑝 = 𝑎𝑝−2 𝑚𝑜𝑑 𝑝

Derived from Fermat’s first theorem


𝑎𝑝−1 ≡ 1 𝑚𝑜𝑑 𝑝
iff
𝑎𝑝−1 𝑚𝑜𝑑 𝑝 = 1 𝑚𝑜𝑑 𝑝
Multiplying both sides by 𝑎−1 , 𝑎𝑝−2 𝑚𝑜𝑑 𝑝 = 𝑎−1 𝑚𝑜𝑑 𝑝
Q. Find 8−1 𝑚𝑜𝑑 17 without using extended Euclidean algorithm.
Euler’s theorem
First version: If a and n are coprime, then 𝑎𝜙(𝑛) ≡ 1 𝑚𝑜𝑑 𝑛
Second version: If 𝑛 = 𝑝 × 𝑞, 𝑎 < 𝑛, and 𝑘 an integer, then
𝑎𝑘×𝜙 𝑛 +1
≡ 𝑎 𝑚𝑜𝑑 𝑛

Q. Find
i. 624 𝑚𝑜𝑑 35
= 6𝜙(35) 𝑚𝑜𝑑 35 = 1
ii. 2062 𝑚𝑜𝑑 77
Some multiplicative inverse can be solved using Euler’s Theorem. If n
and a are coprime, then 𝑎−1 𝑚𝑜𝑑 𝑛 = 𝑎𝜙(𝑛)−1 𝑚𝑜𝑑 𝑝
Q. Find 7−1 𝑚𝑜𝑑 15 without using extended Euclidean algorithm.
Cryptography
Cryptography is the art or science of converting information or data
into an unintelligible data.
• Transforming information so that it cannot be easily recovered
without special knowledge (key).
• Encryption is the process of converting information or data into an
unintelligible data, especially to prevent unauthorized access.
• Decryption is generally the reverse process of encryption. It is the process of
decoding the data which has been encrypted into a unintelligible data.
• Cipher is the unintelligible data obtained after encryption using a key.

Encryption Decryption

Plain Text Cipher Text Decrypted/Deciphered


Text

Fig: A simple Encryption and decryption process


Classical Cryptography
• One of the earliest known uses of cryptography was by Julius Caesar.
He made messages secret by shifting each letter three letters forward
in the alphabet
• f (p) = (p + 3) mod 26.

Q. What is the secret message produced from the message “PARK”


using the Caesar cipher? (Assume A, B, C,…, Z=0,1,2,…,25)
Plaintext PARK 15, 0, 17, 10
Ciphertext SDUN
• CRYPTANALYSIS The process of recovering plaintext from ciphertext
without knowledge of both the encryption method and the key is
known as crytanalysis or breaking codes.

• Cryptanalysis of messages that were encrypted using a shift cipher

• The nine most common letters in English text and their approximate
relative frequencies are E 13%, T 9%, A 8%, O 8%, I 7%, N 7%, S 7%, H
6%, and R 6%
• Suppose that we intercepted the ciphertext message ZNK KGXRE
HOXJ MKZY ZNK CUXS that we know was produced by a shift cipher.
What was the original plaintext message?
• The most common letter in the ciphertext is K.
• Hypothesize that the shift cipher sent the plaintext letter E to the
ciphertext letter K (6 shift, key=6)
A B C D E F G H I J K . . . . Z
0 1 2 3 4 5 6 7 8 9 10 . . . . 25

• Shift the letters of the message by −6, obtaining THE EARLY BIRD GETS
THE WORM
Modern day cryptosystem are
divided into two: Asymmetric key cryptography:
Symmetric key cryptography: Two keys for each communicating entity.
A private key and a public key. If A and B
The sender and receiver uses the
are the communicating entity.
same key (private key).
A’s key are (private_A and public_A).
Similarly, B’s key are (private_B and
public_B).
RSA
(Rivest Shamir Adleman) cryptosystem
RSA is one of the first public-key cryptosystems and is widely used for
secure data transmission. In such a cryptosystem, the encryption key is
public and distinct from the decryption key which is kept secret.
Invented by Rivest, Shamir and Adleman.
Key generation, encryption and decryption algorithm
• Example
• Bob chooses 7 and 11 as p and q and calculates n = 7*11=77.
• The value of 𝜑 𝑛 = 7 − 1 11 − 1 = 60.
• Bob choses e=13 and computes d :
• 𝑑 ≡ 𝑒 −1 mod𝜑 𝑛
i.e. 𝑑 ≡ 13−1 mod 60 (apply Extended Euclidean algorithm to
find the inverse.
On computation you will get d=37.
Bob announces ‘e’ and ‘n’ as public and keeps ‘d’ as secret key.
• Imagine Alice wants to send the plaintext (M) 5 to Bob. She use the public
key𝑒 of Bob to generate the cipher text ‘C’ given by the formula 𝐶 =
𝑀 𝑚𝑜𝑑 𝑛.

So, 𝐶 = 513 𝑚𝑜𝑑 77


Cipher text 𝐶 = 26.
• Bob on receiving the ciphertext 𝐶 = 26, uses his secret/private key to
decipher.
• Plaintext M = 𝐶 𝑑 𝑚𝑜𝑑 𝑛
𝑀 = 2637 𝑚𝑜𝑑 77
M = 5 (which is the plaintext sent by Alice).
Q. Let p=23, q = 31, Bob Choses e=83. Compute d? If Alice wants to
sent the text “CSE”, the ASCII code is (67, 83, 69). Find the cipher text
for each ASCII code. Convert back the cipher text to plaintext using the
private key ‘d’
DIGITAL SIGNATURES
• Not only can cryptography be used to secure the confidentiality of a
message, but it also can be used so that the recipient of the message
knows that it came from the person they think it came from.
• Digital signature can prove the authenticity of the sender of the
message.
• A digital signature needs a public-key system. The signer signs with
the private key; the verifier verifies with the signer’s public key.
• RSA Digital signature schemes

• Signing:
Alice creates a signature out of the message
Using her private exponent, 𝑆 = 𝑀𝑑 𝑚𝑜𝑑 𝑛
And sends the message and the signature to
Bob.
Fig. 2. RSA digital signature scheme

• Verifying:
Bob receives M and S. Bob applies Alice’s public exponent to signature to create a copy of the
message 𝑀′ = 𝑆 𝑒 𝑚𝑜𝑑 𝑛. Bob compares the value of 𝑀′ with the value of 𝑀. If the two values are
congruent, Bob accepts the message.
𝑀′ ≡ 𝑀 𝑚𝑜𝑑 𝑛
→ 𝑆 𝑒 ≡ 𝑀 𝑚𝑜𝑑 𝑛
→ 𝑀𝑑×𝑒 ≡ 𝑀 𝑚𝑜𝑑 𝑛

** From Euler’s theorem 𝑑 × 𝑒 = 1 𝑚𝑜𝑑 𝜑(𝑛)**


Proof of RSA
Cipher text 𝐶 = 𝑀𝑒 𝑚𝑜𝑑 𝑛
Plain text M = 𝐶 𝑑 𝑚𝑜𝑑 𝑛
Assume that the plaintext retrieved by Bob is 𝑀1 . We need to prove that 𝑀1 = 𝑀.
𝑀1 = 𝐶 𝑑 𝑚𝑜𝑑 𝑛 = (𝑀𝑒 𝑚𝑜𝑑 𝑛) 𝑑 𝑚𝑜𝑑 𝑛
𝑀1 = 𝑀𝑒𝑑 𝑚𝑜𝑑 𝑛
We know 𝑑 ≡ 𝑒 −1 mod𝜑 𝑛 or 𝑑 × 𝑒 ≡ 1 mod𝜑 𝑛 .
𝑑 × 𝑒 = 𝑘 × 𝜑 𝑛 + 1, where 𝑘 is an integer.
𝑀1 = 𝑀𝑘×𝜑 𝑛 +1 𝑚𝑜𝑑 𝑛
Second version of Euler’s theorem: If 𝑛 = 𝑝 × 𝑞, 𝑎 < 𝑛 and 𝑘 is an integer, then
𝑎𝑘×𝜑 𝑛 +1 ≡ 𝑎 𝑚𝑜𝑑 𝑛.
𝑀1 = 𝑀 𝑚𝑜𝑑 𝑛
THE CHINESE REMAINDER THEOREM
• Let 𝑚1 , 𝑚2 , … , 𝑚𝑘 be pairwise relatively prime positive integers greater than one and
𝑎1 , 𝑎2 , … , 𝑎𝑘 arbitrary integers. Then the system
𝑥 ≡ 𝑎1 𝑚𝑜𝑑 𝑚1
𝑥 ≡ 𝑎2 𝑚𝑜𝑑 𝑚2
.
𝑥 ≡ 𝑎𝑘 𝑚𝑜𝑑 𝑚𝑘
has a unique solution
Steps.
1. Common modulus 𝑀 = 𝑚1 × 𝑚2 … × 𝑚𝑘 .
𝑀 𝑀 𝑀
2. 𝑀1 = , 𝑀2 = , …, 𝑀𝑘 = .
𝑚1 𝑚2 𝑚𝑘
3. Find multiplicative inverse of
𝑀1 , 𝑀2 , . . . , 𝑀𝑘 using the corresponding moduli 𝑚1 , 𝑚2 , … , 𝑚𝑘 named as 𝑀1−1 ,
𝑀2−1 , . . . , 𝑀𝑘−1 .
4. The solution is 𝑥 = (𝑎1 × 𝑀1 × 𝑀1−1 + 𝑎2 × 𝑀2 × 𝑀2−1 +…+𝑎𝑘 × 𝑀𝑘 × 𝑀𝑘−1 ) mod M
Q. Solve x,
𝑥 ≡ 2 𝑚𝑜𝑑 3
𝑥 ≡ 3 𝑚𝑜𝑑 5
𝑥 ≡ 2 𝑚𝑜𝑑 7

1. 𝑀 = 3 × 5 × 7 = 105.
105 105 105
2. 𝑀1 =
3
= 35, 𝑀2 =
5
= 21, 𝑀3 =
7
= 15.
1 1 1
3. 𝑀1 = 𝑚𝑜𝑑3 = 2, 𝑀2 = 𝑚𝑜𝑑5 = 1, 𝑀3−1
−1 −1
= 𝑚𝑜𝑑7 =1
35 21 15
4. 𝑥 = 2 × 35 × 2 + 3 × 21 × 1 + 2 × 15 × 1 𝑚𝑜𝑑 105 = 23
Applications of Congruence's
• Hashing Functions
One of the most commonly used hashing functions
h(k) = k mod m
• A hashing function h assigns memory location h(k) to the record that has k as its key.
• Eg: Assigning a memory locations in a central computer so that customer records can be
retrieved quickly. Customer records are often identified using the Social Security number
of the customer as the key (k) where m is the number of available memory locations.

• Hashing functions should be easily evaluated so that files can be quickly located.
• Q. Find the memory locations assigned by the hashing function h(k) = k mod 111 to the
records of customers with Social Security numbers 064212848 and 037149212.
h(064212848) = 064212848 mod 111 = 14.
h(037149212) = 037149212 mod 111 = 65,
• Pseudorandom Numbers: Numbers generated by systematic methods that are not truly random.

• The most commonly used procedure for generating pseudorandom numbers is the linear congruential
method. We choose four integers: the modulus m, multiplier a, increment c, and seed x0, with 2 ≤ a < m, 0
≤ c < m, and 0 ≤ x0 < m.
• recursively defined function 𝑥𝑛+1 = 𝑎𝑥𝑛 + 𝑐 𝑚𝑜𝑑 𝑚
• Eg: Find the sequence of pseudorandom numbers generated by the linear congruential method with modulus
m = 9, multiplier a = 7, increment c = 4, and seed x0 = 3.
x1 = 7x0 + 4 mod 9 = 7 ・ 3 + 4 mod 9 = 25 mod 9 = 7,
x2 = 7x1 + 4 mod 9 = 7 ・ 7 + 4 mod 9 = 53 mod 9 = 8,
x3 = 7x2 + 4 mod 9 = 7 ・ 8 + 4 mod 9 = 60 mod 9 = 6,
x4 = 7x3 + 4 mod 9 = 7 ・ 6 + 4 mod 9 = 46 mod 9 = 1,
x5 = 7x4 + 4 mod 9 = 7 ・ 1 + 4 mod 9 = 11 mod 9 = 2,
x6 = 7x5 + 4 mod 9 = 7 ・ 2 + 4 mod 9 = 18 mod 9 = 0,
x7 = 7x6 + 4 mod 9 = 7 ・ 0 + 4 mod 9 = 4 mod 9 = 4,
x8 = 7x7 + 4 mod 9 = 7 ・ 4 + 4 mod 9 = 32 mod 9 = 5,
x9 = 7x8 + 4 mod 9 = 7 ・ 5 + 4 mod 9 = 39 mod 9 = 3.
The sequence :3, 7, 8, 6, 1, 2, 0, 4, 5, 3, 7, 8, 6, 1, 2, 0, 4, 5, 3, . . .
Check Digits
• Congruences are used to check for errors in digit strings. A common technique for detecting errors in such strings is to add
an extra digit at the end of the string. This final digit, or check digit, is calculated using a particular function. Then, to
determine whether a digit string is correct, a check is made to see whether this final digit has the correct value.
• Eg: ISBNs All books are identified by an International Standard Book Number (ISBN-10), a 10-digit code x1x2 . . . x10,
assigned by the publisher.
• The check digit is calculated as:
𝑥10 ≡ σ9𝑖=1 𝑖𝑥𝑖 𝑚𝑜𝑑 11 (either a digit or the letter X (used to represent 10)).
10

෍ 𝑖𝑥𝑖 𝑚𝑜𝑑 11 ≡ 0 𝑚𝑜𝑑 11


𝑖=1
Q. Answer these questions about ISBN-10s:
i. The first nine digits of the ISBN-10 of the sixth edition of this book are 007288008. What is the check digit?
𝑥10 ≡ 1 × 0 + 2 × 0 + 3 × 7 + 4 × 2 + 5 × 8 + 6 × 8 + 7 × 0 + 8 × 0 + 9 × 8 𝑚𝑜𝑑 11 ≡ 182 𝑚𝑜𝑑 11 ≡ 6

ii. Is 084930149X a valid ISBN-10?


Error detection using Cyclic Redundancy code (CRC)

• Message to be transmitted
• Eg: 1011011
• Generator known to both sender and receiver. Let ‘n’ be the length of
the generator.
• Eg: 1101 here n = 4
• Pad n-1 bits as 0’s to the message to be transmitted
• Padded message: 1011011000
• Finding the CRC: Divide the padded message by generator. Reminder
is obtained by performing XOR operation
1101 1011011000 (Padded message) 1101 1011011001 (Without error) 1101 1010011001 (With error)
1101 1101 1101
1100 1100 1110
1101 1101 1101
1110 1110 1111
1101 1101 1101
1100 1101 1000
1101 1101 1101
001 (CRC) 000 (CRC) 1011
1101
110(CRC)
Sender: Receiver:
Message is sent as: 1011011001 CRC=000 No error in received data
Receiver:
CRC≠000 Error in received data
Single bit error detection and correction using Hamming code

• Hamming code developed by R.W. Hamming.


• It pads ‘p’ parity bits to ‘n’ number of data bits which follows the eqn.:2𝑝 ≥ 𝑛 + 𝑝 + 1
• Eg: If n=4, p =3
• The parity bits are placed at 2𝑖 positions
• Eg: Data bits to be transmitted: 1101

1 1 0 1

𝒅𝟕 𝒅𝟔 𝒅𝟓 𝒑𝟒 𝒅𝟑 𝒑𝟐 𝒑𝟏

7 6 5 4(22 ) 3 2(21 ) 1(20 )


𝒑𝟏 → 𝟏, 𝟑, 𝟓, 𝟕
𝒑𝟐 → 𝟐, 𝟑, 𝟔, 𝟕
𝒑𝟒 → 𝟒, 𝟓, 𝟔, 𝟕
Error 𝒑𝟒 𝒑𝟐 𝒑𝟏
position
0(no error) 0 0 0
Calculate parity bits as odd/even parity
1 0 0 1
1 1 0 1 2 0 1 0
7 6 5 4 3 2 1 3 0 1 1
4 1 0 0
5 1 0 1
Assume even parity (even number of 1’s):
𝒑𝟏 = x, 1,0,1 = 0 6 1 1 0
𝒑𝟐 = x, 1,1,1 = 1 7 1 1 1
𝒑𝟒 = x, 0,1,1 = 0

1 1 0 0 1 1 0 Sent to the receiver


Case1: Received with no error Case2: Received with single bit error
1 1 0 0 1 1 0 1 1 0 1 1 1 0

Check: Check:
𝒄𝟏 = 0, 1,0,1 = 0 𝒄𝟏 = 0, 1,0,1 = 0
𝒄𝟐 = 1, 1,1,1 = 0 𝒄𝟐 = 1, 1,1,1 = 0
𝒄𝟒 = 0, 0,1,1 = 0 𝒄𝟒 = 1, 0,1,1 = 1
• 𝒄𝟒 𝒄𝟐 𝒄𝟏 :000 (no error) • 𝒄𝟒 𝒄𝟐 𝒄𝟏 :100 (Error at position
(100)2 = 410 )
• The corrected code will be:
𝒑𝟏 → 𝟏, 𝟑, 𝟓, 𝟕
𝒑𝟐 → 𝟐, 𝟑, 𝟔, 𝟕 1 1 0 0 1 1 0
𝒑𝟒 → 𝟒, 𝟓, 𝟔, 𝟕
Propositional Logic
• Logic is the basis of all mathematical reasoning and of all automated
reasoning.
• Propositions: A proposition is a declarative sentence (that is, a sentence
that declares a fact) that is either true or false, but not both. A proposition
ia a basic building blocks of logic.

• Eg:
• 1 + 1 = 2.
• Toronto is the capital of Canada.
• What time is it?
• x + 1 = 2.
• Propositional variables (or statement variables): Variables that
represent propositions. The conventional letters used for
propositional variables are p, q, r, s, . . . .
• If the proposition is true, it is denoted by T. If the proposition is false,
it is denoted by F.
• The area of logic that deals with propositions is called the
propositional calculus or propositional logic.

• Many mathematical statements are constructed by combining one or


more propositions. New propositions, called compound propositions,
are formed from existing propositions using logical operators.
1. Negation of p: Let p be a proposition. The negation of p, denoted by ¬𝑝
(also denoted by 𝑝) read as “not p”, is the statement “It is not the case
that p.”
• Eg: Find the negation of the proposition
Truth table
“Michael’s PC runs Linux”
𝑝 ¬𝑝
and express this in simple English.
T F
“It is not the case that Michael’s PC runs Linux.” F T
“Michael’s PC does not run Linux.”

Q. Find the negation of the proposition


“Vandana’s smartphone has at least 32GB of memory”
and express this in simple English.
“It is not the case that Vandana’s smartphone has at least 32GB of
memory.”
“Vandana’s smartphone does not have at least 32GB of memory”
“Vandana’s smartphone has less than 32GB of memory.”

2. Conjunction of p and q: 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.
Truth table
𝑝 𝒒 𝑝∧𝑞
T T T
T F F
F T F
F F F
3. Disjunction of p and q: 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.
Truth table
𝑝 𝒒 𝑝∨𝑞 𝑝⊕𝑞

T T T F
T F T T
F T T T
F F F F

4. Exclusive or of p and q: 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.
5. Conditional Statements: 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). A conditional statement is also called an
implication.
• Note that the statement p → q is true when both p and q are true and when p is false (no
matter what truth value q has).
• “If you get 100% on the final, then you will get an A.”

Truth table Truth table


𝑝 𝒒 𝑝→𝑞 𝑝 𝒒 ¬𝒑 ¬𝒑 ∨ 𝒒 𝑝→𝑞
T T T T T F T T
T F F T F F F F
F T T F T T T T
F F T F F T T T
Expressing conditional statement:
1. “if p, then q” 2. “p implies q”
3. “if p, q” 4. “p only if q”
5. “p is sufficient for q” 6. “a sufficient condition for q is p”
7. “q if p” 8. “q whenever p”
9. “q when p” 10. “q is necessary for p”
11. “a necessary condition for p is q” 12. “q follows from p”
13. “q unless ¬p”
Q. 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.
p: Maria learns discrete mathematics.
q: Maria will find a good job.
“if p, then q”
“If Maria learns discrete mathematics, then she will find a good job.”
“q when p”
“Maria will find a good job when she learns discrete mathematics.”
“q unless ¬p”
“Maria will find a good job unless she does not learn discrete mathematics.”
CONVERSE, CONTRAPOSITIVE, AND INVERSE
CONVERSE: The converse of p → 𝑞 is the proposition q → 𝑝.
CONTRAPOSITIVE: The contrapositive of p → 𝑞 is the proposition ¬𝑞 → ¬𝑝.
INVERSE: The inverse of p → 𝑞 is the proposition ¬p → ¬𝑞.
Q. Find the truth table for converse, contrapositive and inverse:
p q Converse: Contrapositive: Inverse:
q→𝑝 ¬𝑞 → ¬𝑝 ¬p → ¬𝑞
T T
T F
F T
F F

Only the contrapositive always has the same truth value as p → q. When two
compound propositions always have the same truth value we call them
equivalent. A conditional statement and its contrapositive are equivalent.
Q. What are the contrapositive, the converse, and the inverse of the
conditional statement
“The home team wins whenever it is raining?”
“q whenever p”
q: The home team wins
p: It is raining.
“The home team wins whenever it is raining?”
“q whenever p”
q: The home team wins
p: It is raining.

Contrapositive ¬𝑞 → ¬𝑝 : “If the home team does not win, then it is


not raining.”
Converse q → 𝑝 : “If the home team wins, then it is raining.”
Inverse ¬p → ¬𝑞: “If it is not raining, then the home team does not
win.”
BICONDITIONALS: Let p and q be propositions. The biconditional statement
p ↔ q is the proposition “p if and only if q.” Biconditional statements are also
called bi-implications.
p ↔ q has exactly the same truth value as (p → q) ∧ (q → p).
Q. Find the truth table for p ↔ q
p q p→𝒒 𝑞→𝑝 p⟷𝑞
T T
T F
F T
F F

Q. 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?
Q. Construct the truth table of the compound proposition
(p ∨¬q) → (p ∧ q).

Precedence of Logical Operators


Operator Precedence
¬ 1
∧ 2
∨ 3
→ 4
↔ 5
Q. Let p, q, and r be the propositions
p :You have the flu.
q :You miss the final examination.
r :You pass the course.
Express each of these propositions as an English sentence.
a) p → q b) ¬q ↔ r
c) q →¬r d) p ∨ q ∨ r
e) (p →¬r) ∨ (q →¬r)
f ) (p ∧ q) ∨ (¬q ∧ r)
Sometimes in logic, the word “but” is used instead of “and”.

The sun is shining, but it is raining.

Expressing it using logical connective:


p: The sun is shining.
q: It’s raining

𝑝∧𝑞
Q. Let p, q, and r be the propositions
p : Grizzly bears have been seen in the area.
q : Hiking is safe on the trail.
r : Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives (including
negations).
a) Berries are ripe along the trail, but grizzly bears have not been seen in the
area.
b) Grizzly bears have not been seen in the area and hiking on the trail is safe,
but berries are ripe along the trail.
c) If berries are ripe along the trail, hiking is safe if and only if grizzly bears
have not been seen in the area.
d) It is not safe to hike on the trail, but grizzly bears have not been seen in
the area and the berries along the trail are ripe.
e ) Hiking is not safe on the trail whenever grizzly bears have been seen in
the area and berries are ripe along the trail.
p : Grizzly bears have been seen in the area.
q : Hiking is safe on the trail.
r : Berries are ripe along the trail.
Write these propositions using p, q, and r and logical connectives (including negations).
a) Berries are ripe along the trail, but grizzly bears have not been seen in the area.
𝑟 ∧ ¬𝑝
b) Grizzly bears have not been seen in the area and hiking on the trail is safe, but berries are ripe along the
trail.
¬𝑝 ∧ 𝑞 ∧ 𝑟

c) If berries are ripe along the trail, hiking is safe if and only if grizzly bears have not been seen in the area.
𝑟 → (𝑞 ↔ ¬𝑝)

d) It is not safe to hike on the trail, but grizzly bears have not been seen in the area and the berries along the
trail are ripe.
¬ 𝑞 ∧ ¬𝑝 ∧ 𝑟
e ) Hiking is not safe on the trail whenever grizzly bears have been seen in the area and berries are ripe along
the trail.
𝑝 ∧ 𝑟 → ¬𝑞
Q. Let p, q, and r be the propositions and:
but/nevertheless/however/even
p :You get an A on the final exam. so/inspite/yet/though/still/nonetheless/anyhow/an
q :You do every exercise in this book. yway

r :You get an A in this class.


Write these propositions using p, q, and r and logical connectives (including
negations).
a) You get an A in this class, but you do not do every exercise in this book.
b) You get an A on the final, you do every exercise in this book, and you get an A in this
class.
c) To get anA in this class, it is necessary for you to get an A on the final.
d) You get an A on the final, but you don’t do every exercise in this book; nevertheless,
you get an A in this class.
e) Getting an A on the final and doing every exercise in this book is sufficient for
getting an A in this class.
f ) You will get an A in this class if and only if you either do every exercise in this book
or you get an A on the final.
p :You get an A on the final exam.
q :You do every exercise in this book.
r :You get an A in this class.
Write these propositions using p, q, and r and logical connectives (including negations).
a) You get an A in this class, but you do not do every exercise in this book.
𝑝 ∧ ¬𝑞
b) You get an A on the final, you do every exercise in this book, and you get an A in this class.
𝑝∧𝑞∧𝑟
c) To get an A in this class, it is necessary for you to get an A on the final.
𝑟→𝑝
d) You get an A on the final, but you don’t do every exercise in this book; nevertheless, you get an A in this class.
𝑝 ∧ ¬𝑞 ∧ 𝑟
e) Getting an A on the final and doing every exercise in this book is sufficient for getting an A in this class.
𝑝∧𝑞 →𝑟
f ) You will get an A in this class if and only if you either do every exercise in this book or you get an A on the
final.
𝑟 ↔ (𝑞 ∨ 𝑟)
Q. Write each of these statements in the form “if p, then q”
a) It snows whenever the wind blows from the northeast.
b) The apple trees will bloom if it stays warm for a week.
c) That the Pistons win the championship implies that they beat the Lakers.
d) It is necessary to walk 8 miles to get to the top of Long’s Peak.
e) To get tenure as a professor, it is sufficient to be world famous.
f ) If you drive more than 400 miles, you will need to buy gasoline.
g) Your guarantee is good only if you bought your CD player less than 90 days
ago.
h) Jan will go swimming unless the water is too cold.
Write each of these statements in the form “if p, then q”
a) It snows whenever the wind blows from the northeast. 𝑞 𝑤ℎ𝑒𝑛𝑒𝑣𝑒𝑟 𝑝
If the wind blows from the northeast, then it snows
b) The apple trees will bloom if it stays warm for a week. 𝑞 𝑖𝑓 𝑝
If it stays warm for a week, then the apple trees will bloom
c) That the Pistons win the championship implies that they beat the Lakers. 𝑝 𝑖𝑚𝑝𝑙𝑖𝑒𝑠 𝑞
If the Pistons win the championship, then they beat the Lakers.
d) It is necessary to walk 8 miles to get to the top of Long’s Peak.
What is necessary to get to the top of Long’s Peak : to walk 8 miles (conclusion/consequence)
If you get to the top of Long’s Peak, then must have walked 8 miles.
e) To get tenure as a professor, it is sufficient to be world famous.
What is sufficient to get tenure as a professor: to be world famous (hypothesis/antecedent/premise)
If you are world famous, then you will get tenure as a professor.
f ) If you drive more than 400 miles, you will need to buy gasoline.
If you drive more than 400 miles, then you will need to buy gasoline.
g) Your guarantee is good only if you bought your CD player less than 90 days ago. 𝑝 𝑜𝑛𝑙𝑦 𝑖𝑓 𝑞
If your guarantee is good, then you have bought your CD player less than 90 days ago.
h) Jan will go swimming unless the water is too cold. 𝑞 𝑢𝑛𝑙𝑒𝑠𝑠 𝑛𝑜𝑡 𝑝
If the water is not too cold, then Jan will go swimming.
Translating English Sentences
• Translate the English sentences into expressions involving
propositional variables and logical connectives
• Once we have translated sentences from English into logical
expressions we can analyze these logical expressions to determine
their truth values, we can manipulate them, and we can use rules of
inference (will be taught later) to reason about them.
Q. Translated into a logical expression
“You can access the Internet from campus only if you are a computer
science major or you are not a freshman.”
• “You can access the Internet from campus”: a
• “You are a computer science major”: c
• “You are a freshman”: f
𝑎 → (𝑐 ∨ ¬𝑓)
Q. “You cannot ride the roller coaster if you are under 4 feet tall unless you are
older than 16 years old.”
r: You can ride the roller coaster.
u: you are under 4 feet tall.
o: you are older than 16 years old.
(𝑢 ∧ ¬𝑜) → ¬𝑟

Q. The automated reply cannot be sent when the file system is full
a: The automated reply can be sent.
f: The file system is full.
𝑓 → ¬𝑎
System specifications should be consistent, that is, they should not contain
conflicting requirements that could be used to derive a contradiction.
Q. Determine whether these system specifications are consistent:
“The diagnostic message is stored in the buffer or it is retransmitted.”
“The diagnostic message is not stored in the buffer.”
“If the diagnostic message is stored in the buffer, then it is retransmitted.”
p: The diagnostic message is stored in the buffer .
q: The diagnostic message is retransmitted.
𝑝∨𝑞
¬𝑝 p q 𝑝∨𝑞 ¬𝑝 𝑝→𝑞
𝑝→𝑞 T T T F T
T F T F F
F T T T T
F F F T T
Logic Puzzles: Puzzles that can be solved using logical reasoning are known as logic puzzles.
• An island that has two kinds of inhabitants, knights, who always tell the truth, and their opposites,
knaves, who always lie. You encounter two people A and B. What are A and B if A says “B is a
knight” and B says “The two of us are opposite types?”
• Let
• 𝑝 : A is a knight. and ¬𝑝: A is knave
• 𝑞: B is a knight. and¬𝑞: B is knave

Assume A is a knight.
If A is a knight, then he is telling the truth when he says that B is a knight.
However, if B is a knight, then B’s statement that A and B are of opposite types contradicts. We can
conclude that A is not a knight, that is, that p is false.

Assume A is a knave.
If A is a knave, then everything A says is false. A’s statement that B is a knight is a lie. Means that q is
false and B is also a knave. If B is a knave, then B’s statement that A and B are opposite types is a lie
which is consistent with both A and B being knaves.
• We can conclude that both A and B are knaves.
Logic Circuits

Q. Build a digital circuit that produces the output (p ∨¬r) ∧ (¬p ∨ (q


∨¬r)) when given input bits p, q, and r.
Propositional Equivalences
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.
• Logical Equivalences: Compound propositions that have the same
truth values in all possible cases are called logically equivalent. The
symbol ≡ or ⇔is used to denote logical equivalence.
• The compound propositions p and q are called logically equivalent if p
↔ q is a tautology.

• De Morgan laws:
1. ¬(p ∧ q) ≡ ¬p ∨¬q
2. ¬(p ∨ q) ≡ ¬p ∧¬q
Q. Show that ¬(p ∨ q) and ¬p ∧¬q are logically equivalent.
Q. Show that p ∨ (q ∧ r) and (p ∨ q) ∧ (p ∨ r) are logically equivalent.
Equivalence Name
p∧T≡p Identity laws
Logical Equivalences. p∨F≡p
p∨T≡T Domination laws
p∧F≡F
p∨p≡p Idempotent laws
p∧p≡p
¬(¬p) ≡ p Double negation law
p∨q≡q∨p Commutative laws
p∧q≡q∧p
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r) Associative laws
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r) Distributive laws
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
¬(p ∧ q) ≡ ¬p ∨¬q De Morgan’s laws
¬(p ∨ q) ≡ ¬p ∧¬q
p ∨ (p ∧ q) ≡ p Absorption laws
p ∧ (p ∨ q) ≡ p
p ∨¬p ≡ T Negation laws
p ∧¬p ≡ F
Logical Equivalences
Involving Conditional Statements.
• p → q ≡ ¬p ∨ q
• p → q ≡ ¬q →¬p
• p ∨ q ≡ ¬p → q
• p ∧ q ≡ ¬(p →¬q)
• ¬(p → q) ≡ p ∧¬q
• (p → q) ∧ (p → r) ≡ p → (q ∧ r)
• (p → r) ∧ (q → r) ≡ (p ∨ q) → r
• (p → q) ∨ (p → r) ≡ p → (q ∨ r)
• (p → r) ∨ (q → r) ≡ (p ∧ q) → r
Logical Equivalences Involving
Biconditional Statements.

• p ↔ q ≡ (p → q) ∧ (q → p)
• p ↔ q ≡ ¬p ↔¬q
• p ↔ q ≡ (p ∧ q) ∨ (¬p ∧¬q)
• ¬(p ↔ q) ≡ p ↔¬q
Q. Show that ¬(p → q) and p ∧¬q are logically equivalent.

¬(p → q) ≡ ¬(¬p ∨ q) since p → q ≡ ¬p ∨ q


≡ ¬(¬p)∧¬q by the second De Morgan law
≡ p ∧¬q by the double negation law
Q. Show that ¬(p ∨ (¬p ∧ q)) and ¬p ∧¬q are logically equivalent by
developing a series of logical equivalences.
• Q. Show that ¬(p ∨ (¬p ∧ q)) and ¬p ∧¬q are logically equivalent by
developing a series of logical equivalences.

¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧¬(¬p ∧ q) by the second De Morgan law


≡ ¬p ∧ [¬(¬p)∨¬q] by the first De Morgan law
≡ ¬p ∧ (p ∨¬q) by the double negation law
≡ (¬p ∧ p) ∨ (¬p ∧¬q) by the second distributive law
≡ F ∨ (¬p ∧¬q) because ¬p ∧ p ≡ F
≡ (¬p ∧¬q) ∨ F by the commutative law for disjunction
≡ ¬p ∧¬q by the identity law for F
• Consequently ¬(p ∨ (¬p ∧ q)) and ¬p ∧¬q are logically equivalent.
Q. “You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16 years old.”
r: You can ride the roller coaster.
u: you are under 4 feet tall.
o: you are older than 16 years old.
(𝑢 ∧ ¬𝑜) → ¬𝑟
• You cannot ride the roller coaster if you are under 4 feet tall unless you are older than 16 years old
p → q ≡ q unless ¬p ≡If p, q
≡¬r if u unless o
≡¬𝑜 →(¬r if u)
≡¬𝑜 →(u → ¬r)
≡ ¬𝑜 →(¬𝑢 ∨ ¬𝑟)
≡ ¬(¬𝑜) ∨ ¬𝑢 ∨ ¬𝑟
≡ 𝑜 ∨ ¬𝑢 ∨ ¬𝑟
≡(𝑜 ∨ ¬𝑢) ∨ ¬𝑟
≡ ¬(¬o ∧u) ∨ ¬𝑟
≡¬(u ∧ ¬o ) ∨ ¬𝑟
≡(u ∧ ¬o)→ ¬𝑟

If a then b unless c ≡ (𝑎 ∧ ¬𝑐) → 𝑏


Q. Show that (p ∧ q) → (p ∨ q) is a tautology.

(p ∧ q) → (p ∨ q) ≡ ¬(p ∧ q) ∨ (p ∨ q)
≡ (¬p ∨¬q) ∨ (p ∨ q) by the first De Morgan law
≡ (¬p ∨ p) ∨ (¬q ∨ q) by the associative and commutative
laws for disjunction
≡T∨T
≡ T by the domination law
Propositional Satisfiability
A compound proposition is satisfiable if there is an assignment of truth
values to its variables that makes it true. When no such assignments exists,
that is, when the compound proposition is false for all assignments of truth
values to its variables, the compound proposition is unsatisfiable.
Q. Determine whether each of the compound propositions
i. (p ∨¬q) ∧ (q ∨¬r) ∧ (r ∨¬p)
ii. (p ∨ q ∨ r) ∧ (¬p ∨¬q ∨¬r), is satisfiable.
i, When p=T; q=T; r=T; (p ∨¬q) ∧ (q ∨¬r) ∧ (r ∨¬p) will be T, hence it
satisfiable
Q. Show that each of these conditional statements is a tautology
a) (p ∧ q) → p b) p → (p ∨ q)
c) ¬p → (p → q) d) (p ∧ q) → (p → q)
e) ¬(p → q) → p f ) ¬(p → q)→¬q

a) (p ∧ q) → p ≡ ¬ 𝑝 ∧ 𝑞 ∨ 𝑝 ≡ ¬𝑝 ∨ ¬𝑞 ∨ 𝑝 ≡ ¬𝑝 ∨ 𝑝 ∨ ¬𝑞 ≡ 𝑇 ∨ ¬𝑞 ≡ 𝑇
f) ¬(p → q)→¬q ≡ ¬(¬𝑝 ∨ 𝑞) → ¬𝑞 ≡ (𝑝 ∧ ¬𝑞) → ¬𝑞
≡ ¬(𝑝 ∧ ¬𝑞) ∨ ¬𝑞 ≡ ¬𝑝 ∨ 𝑞 ∨ ¬𝑞 ≡ ¬𝑝 ∨ 𝑇 ≡ 𝑇

Q. Determine whether (¬p ∧ (p → q))→¬q is a tautology.


Q. Show that p ↔ q and (p → q) ∧ (q → p) are logically equivalent.
Prove
i. p ∨ (p ∧ q) ≡ p
ii. p ∧ (p ∨ q) ≡ p
Q. Show that ¬(p ↔ q) and ¬p ↔q are logically equivalent.
To show: ¬(p ↔ q) ≡ ¬p ↔q

L.H.S
¬(p ↔ q) ≡ ¬ 𝑝 → 𝑞 ∧ 𝑞 → 𝑝
≡ ¬ ¬𝑝 ∨ 𝑞 ∧ ¬𝑞 ∨ 𝑝
≡ ¬ ¬𝑝 ∧ ¬𝑞 ∨ (¬𝑝 ∧ 𝑝) ∨ (𝑞 ∧ ¬𝑞) ∨ 𝑞 ∧ 𝑝
≡ ¬ ¬𝑝 ∧ ¬𝑞 ∨ 𝐹 ∨ 𝐹 ∨ 𝑞 ∧ 𝑝
≡ ¬ ¬𝑝 ∧ ¬𝑞 ∧ 𝑇 ∧ 𝑇 ∧ ¬ 𝑞 ∧ 𝑝
≡ 𝑝 ∨ 𝑞 ∧ ¬𝑞 ∨ ¬𝑝
≡ ¬𝑝 → 𝑞 ∧ 𝑞 → ¬𝑝
≡ ¬𝑝 ↔ 𝑞
Q. Show that ¬(p ↔ q) and p ↔ ¬ q are logically equivalent.

Q. Show that p → q and ¬q →¬p are logically equivalent.


To show: p → q ≡ ¬q →¬p

L.H.S.
p → q ≡ ¬𝑝 ∨ 𝑞
≡ 𝑞 ∨ ¬𝑝
≡ ¬(¬𝑞) ∨ ¬𝑝
≡ ¬q →¬p
Q. Show using truth table, ¬(p ⊕ q) and p ↔ q are logically
equivalent.
Q. Show that ¬(p ⊕ q) and p ↔ q are logically equivalent without
using truth table.
Hint: A ⊕ B=A𝐵+ത 𝐴ҧ B
Q. Determine whether [(p ∨ q) ∧ (¬p ∨ r)] → (q ∨ r) is a tautology or
not.
Q. Show that (p → q) → r and p → (q → r) are not logically equivalent.

When p, q and r are all F.


(p → q) → r is F
p → (q → r) is T

So, (p → q) → r and p → (q → r) are not logically equivalent.


Predicates and Quantifiers
Predicates:
Statements involving variables, “x > 3”, “x = y + 3”
These statements are neither true nor false when the values of the variables
are not specified.
The statement “x is greater than 3” has two parts. The first part, the variable x,
is the subject of the statement. The second part—the predicate, “is greater
than 3”—refers to a property that the subject of the statement can have.
• We can denote the statement “x is greater than 3” by P(x), where P denotes
the predicate “is greater than 3” and x is the variable.
• The statement P(x) is also said to be the value of the propositional function
P at x. Once a value has been assigned to the variable x, the statement P(x)
becomes a proposition and has a truth value.
Q. Let P(x) denote the statement “x > 3.” What are the truth values of
P(4) and P(2)?

Q. 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)?

Q. 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)?
Quantifiers

• Quantification expresses the extent to which a predicate is true over a


range of elements. In English, the words all, some, many, none, and few
are used in quantifications.
• We will focus on two types of quantification here: universal
quantification, which tells us that a predicate is true for every element
under consideration, and existential quantification, which tells us that
there is one or more element under consideration for which the
predicate is true. The area of logic that deals with predicates and
quantifiers is called the predicate calculus.
The universal quantification of P(x) is the statement
“P(x) for all values of x in the domain.”
The notation ∀xP(x) denotes the universal quantification of P(x). Here ∀ is called the
universal quantifier. We read ∀xP(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 ∀xP(x).

Eg: 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?
• Because P(x) is true for all real numbers x, the quantification ∀xP(x) is true.
Eg: 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?
• 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.
• The existential quantification of P(x) is the proposition
“There exists an element x in the domain such that P(x).”
We use the notation ∃xP(x) for the existential quantification of P(x).
Here ∃ is called the existential quantifier.
• 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.”

• Eg: 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?
• Because “x > 3” is sometimes true—for instance, when x = 4 the
existential quantification of P(x), which is ∃xP(x), is true.
Statement When True? When False?
∀xP(x) P(x) is true for every x. There is an x for which P(x) is false
∃xP(x) There is an x for which P(x) is true. P(x) is false for every x.

THE UNIQUENESS QUANTIFIER

The uniqueness quantifier, denoted by ∃! or ∃1.


The notation ∃!xP(x) [or ∃1xP(x)] states “There exists a unique x such that P(x)
is true.”
Other phrases for uniqueness quantification include “there is exactly one” and
“there is one and
only one.”)
Quantifiers with Restricted Domains
• An abbreviated notation is often used to restrict the domain of a quantifier. In
this notation, a condition a variable must satisfy is included after the quantifier.
• Eg: What do the statements ∀x < 0 (x2 > 0), ∀y ≠ 0 (y3 ≠ 0), and ∃z > 0 (z2 = 2)
mean, where the domain in each case consists of the real numbers?
• The statement ∀x < 0 (x2 > 0) states that for every real number x with x < 0, x2 > 0.
That is, it states “The square of a negative real number is positive.” This
statement is the same as ∀x(x < 0 → x2 > 0).
• The statement ∀y ≠ 0 (y3 ≠ 0) states that for every real number y with y ≠ 0, we
have y3 ≠ 0. That is, it states “The cube of every nonzero real number is nonzero.”
Note that this statement is equivalent to ∀y(y ≠ 0 → y3 ≠ 0).
• Finally, the statement ∃z > 0 (z2 = 2) states that there exists a real number z with z
> 0 such that z2 = 2. That is, it states “There is a positive square root of 2.” This
statement is equivalent to ∃z(z > 0 ∧ z2 = 2).
Precedence of Quantifiers
The quantifiers ∀ and ∃ have higher precedence than all logical
operators from propositional calculus.
For example, ∀xP(x) ∨ Q(x) is the disjunction of ∀xP(x) and Q(x).
In other words, it means (∀xP(x)) ∨ Q(x) rather than ∀x(P(x) ∨ Q(x)).
Logical Equivalences Involving Quantifiers
Statements involving predicates and quantifiers are logically equivalent
if and only if they have the same truth value no matter which
predicates are substituted into these statements and which domain of
discourse is used for the variables in these propositional functions. We
use the notation S ≡ T to indicate that two statements S and T involving
predicates and quantifiers are logically equivalent.
Negating Quantified Expressions
• “Every student in your class has taken a course in calculus.”
∀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.”
∃x ¬P(x).
The rules for negations for quantifiers are called De Morgan’s laws for quantifiers.

Negation Equivalent Statement

¬∃xP(x) ∀x¬P(x)

¬∀xP(x) ∃x¬P(x)

Q. What are the negations of the statements “There is an honest politician” and “All Americans eat
cheeseburgers”?
Let H(x) denote “x is honest.”
“There is an honest politician” is represented by ∃xH(x), where the domain consists of all politicians.
The negation of this statement is ¬∃xH(x), which is equivalent to ∀x¬H(x).
“Every politician is dishonest.”
In English, the statement “All politicians are not honest” is ambiguous, this statement often means “Not all
politicians are honest.”
• “All Americans eat cheeseburgers”

Let C(x) denote “x eats cheeseburgers.”


“All Americans eat cheeseburgers”: ∀xC(x), where the domain consists of all
Americans.
¬∀xC(x) is given by ∃x¬C(x).
“Some American does not eat cheeseburgers”
“There is an American who does not eat cheeseburgers.”

Q. What are the negation of the statements ∀x(x2 > x).


¬∀x(x2 > x), which is equivalent to ∃x¬(x2 > x).
This can be rewritten as ∃x(x2 ≤ x).

Q. What are the negation of the statements ∃x(x2 = 2)


What are the negation of the statements ∃x(x2 = 2)

¬∃x(x2 = 2), which is equivalent to ∀x¬(x2 = 2). This can be rewritten


as ∀x(x2 ≠ 2).

Q. Show that ¬∀x(P(x) → Q(x)) and ∃x(P(x)∧¬Q(x)) are logically


equivalent.
¬∀x(P(x) → Q(x))≡ ∃x(¬(P (x) → Q(x)))
≡ ∃x(¬(¬P (x) ∨ Q(x)))
≡ ∃x(P (x) ∧ ¬Q(x))
Translating from English into Logical
Expressions
Q. Express the statement “Every student in this class has studied
calculus” using predicates and quantifiers.

Rewrite the statement by introduce a variable x so that we can clearly


identify the appropriate quantifiers to use.
“For every student x in this class, x has studied calculus.”
C(x): x has studied calculus.
∀xC(x), where the domain for x consists of the students in the class
Q. Express the statement “For every person x, if person x is a student in
this class then x has studied calculus.” using predicates and quantifiers

S(x): person x is in this class


C(x): x has studied calculus.
∀x(S(x) → C(x)), where the domain consist of all people.

The above statement cannot be expressed as ∀x(S(x) ∧C(x)) because


this statement says that all people are students in this class and have
studied calculus
Q. Express the statement “Some student in this class has visited Mexico” using
predicates and quantifiers.

“Some student in this class has visited Mexico”


There exist some student x in this class such that x has visited Mexico
M(x): x has visited Mexico.
∃𝑥𝑀 𝑥 , where domain consist of student in the class.

“There is a person x having the properties that x is a student in this class and x
has visited Mexico.”
S(x): x is a student in this class.
M(x): x has visited Mexico.
∃𝑥(𝑆(𝑥) ∧ 𝑀 𝑥 ), where the domain consist of all people.
Q. “For every student x in this class, x has the property that x has visited Mexico or x has visited
Canada.”
M(x): x has visited Mexico.
C(x): x has visited Canada.
∀𝑥(𝐶(𝑥) ∨ 𝑀 𝑥 ), where domain consist of student in the class.

Q. “For every person x, if x is a student in this class, then x has visited Mexico or x has visited Canada.”
S(x): x is a student in this class.
M(x): x has visited Mexico.
C(x): x has visited Canada.

∀ 𝑥(𝑆(𝑥) → (𝐶(𝑥) ∨ 𝑀 𝑥 ) where the domain consist of all people.

V(x, Mexico): x has visited Mexico.


V(x, Canada): x has visited Canada.

∀ 𝑥(𝑆(𝑥) → (𝑉(𝑥, 𝑀𝑒𝑥𝑖𝑐𝑜) ∨ 𝑉 𝑥, 𝐶𝑎𝑛𝑎𝑑𝑎 )


Q. Use predicates and quantifiers to express the system specifications
“Every mail message larger than one megabyte will be compressed”
• S(m, 1): Mail message m is larger than 1 megabytes, where the variable m has
the domain of all mail messages.
C(m): Mail message m will be compressed.
∀m(S(m, 1) → C(m))
“If a user is active, at least one network link will be available.”
A(u): User u is active.
• S(n, available): Network link n is in available, where n has the domain of all
network links.
∃uA(u) → ∃nS(n, available)
Q. Consider these statements. The first two are called premises and the third is
called the conclusion. The entire set is called an argument.
“All lions are fierce.”
“Some lions do not drink coffee.”
“Some fierce creatures do not drink coffee.”
P(x): x is a lion.
Q(x): x is fierce.
R(x): x drinks coffee.
∀x(P(x) → Q(x)).
∃x(P(x) ∧ ¬R(x)).
∃x(Q(x) ∧ ¬R(x)).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy