Discrete Structures For Computer Science (SEHEXZC222) : BITS Pilani

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

DISCRETE STRUCTURES FOR

COMPUTER SCIENCE
(SEHEXZC222)
Faculty Name : Dr. ANITHA N
  Mail-Id : [email protected]
BITS Pilani
Pilani|Dubai|Goa|Hyderabad
BITS Pilani
Hyderabad Campus

Contact Sesion 1
Syllabus

 Module 1: Propositional Logic, Propositional Equivalence,


Predicate Logic, Introduction to logic; basic concepts in
propositional logic, operators on propositions, knowledge
representation in propositional logic, propositional equivalence
using truth tables, equivalence laws, and fundamentals of predicate
logic, quantifier expressions, knowledge representation in predicate
logic.
 Module 2: Proof Methods
Inference Rules, Proof Methods, Strong & Weak induction
Inference rules, proof methods – direct proof, indirect proof,
vacuous proof, trivial proof, proof by cases, proof by contradiction
and strong / weak induction
 Module 3:Sets, Functions and Relations
Set theory, Functions, Relations – Equivalence Relations, Partial
Order Relations, Lattices.
Introduction to set theory, set relations, set operators, cardinality of
sets, Cartesian product of sets, fundamentals of functions – range,
domain, injection, surjection, bijection of functions, fundamentals
of relations, reflexive, symmetric and transitive properties in
relations, representing relations, applications of relations,
equivalence relations, partial order relations, lattices.
Module 4: Combinatory, Recursion, Recurrence relation
Combinatorics, Pigeonhole principle, Recursion, Recursively
defined functions, Recurrence relations
Combinatorics: sum and product rules, inclusion/exclusion
principle, pigeonhole principle, recursion, recursively defined
functions, recurrence relations.
Module 5:Graph Theory
Introduction to graph theory, Trees, Minimum Spanning Trees.
Introduction to graph theory, directed and undirected graphs,
handshaking theorem, special graph structures, graph
representations and isomorphism of graphs, connectedness,
components, Euler, Hamilton paths and cycles, trees, binary
trees, binary search tree, spanning trees, minimum spanning
trees – Prim’s and Kruskal’s algorithms.
Module 6:Introduction to Cryptography
Basic Number Theory, Introduction to Cryptography, RSA
Algorithm
Basic concepts in number theory, prime factorization theorem,
division algorithm, primality, modular congruence, Euclid’s
algorithm for GCD, hash functions, modular exponential
problem, Chinese remainder theorem, RSA algorithm.
Textbook
Discrete Mathematics and Its Applications
by Kenneth H. Rosen, 7th edition, McGraw Hill
Agenda

 1.1 Propositional logic

 1.2 Translating English to logical expressions

 1.3 Propositional equivalences


What are “discrete structures ”
“Discrete” - Composed of distinct, separable parts.
(Opposite of continuous.)
discrete: continuous :: digital: analog
“Structures ” - objects built up from simpler objects according
to a definite pattern.
1.1 Propositional logic
Understand and construct correct mathematical arguments
Give precise meaning to mathematical statements
Rules are used to distinguish between valid (true) and invalid
arguments
Used in numerous applications: circuit design, programs,
verification of correctness of programs, artificial intelligence,
etc.

10
Proposition
A declarative sentence that is either true or false, but not both
– Washington, D.C., is the capital of USA
– California is adjacent to New York
– 1+1=2
– 2+2=5
– What time is it?
– Read this carefully

11
Logical operators
Negation operator
Conjunction (and, ^)
Disjunction (or v )
Conditional statement 
Biconditional statement 
Exclusive Or

12
Negation

13
Example
“Today is Friday”
– It is not the case that today is Friday
– Today is not Friday
At least 10 inches of rain fell today in Miami
– It is not the case that at least 10 inches of rain fell today in
Miami
– Less than 10 inches of rain fell today in Miami

14
Conjunction

Conjunction: p ^ q is true when both p and q are true. False otherwise

15
Example
p: “Today is Friday”, q: “It is raining today”
p˄q “Today is Friday and it is raining today”
– true: on rainy Fridays
– false otherwise:
• Any day that is not a Friday
• Fridays when it does not rain

16
Disjunction

Disjunction: p v q is false when both p and q are false. True otherwise

17
Example
p ˅ q: “Today is Friday or it is raining today”
– True:
• Today is Friday
• It is raining today
• It is a rainy Friday
– False
• Today is not Friday and it does not rain

18
Exclusive or

Exclusive Or is true when exactly one


of p, q is true. False otherwise

19
Conditional statement

Conditional Statement:
• p is called the premise (or antecedent) and q is called the conclusion
(or consequent)
• p q is false when p is true and q is false. True otherwise

20
Conditional statement pq
Also called an implication

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
q unless ┐ p
Conditional Statement: pq is false when p is true and q is false. True otherwise
Example
p: you go, q: I go. pq means “If you go, then I go” is equivalent to p only if q “You go
only if I go” (not the same as “I go only if you go” which is q only if p)

21
pq

p only if q:
– p cannot be true when q is not true
– The statement is false if p is true but q is
false
– When p is false, q may be either true or
false
– Not to use “q only if p” to express pq
q unless ┐ p
– If ┐ p is false, then q must be true
– The statement is false when p is true but q
is false, but the statement is true otherwise

22
.
E.g.,
let p = “You study hard”.
q = “You will get a good grade”.
p → q = “If you study hard, then you will get a good grade
Example
If Maria learns discrete mathematics, then she will find a good
job
– Maria will find a good job when she learns discrete
mathematics (q when p)
– For Maria to get a good job, it is sufficient for her to learn
discrete mathematics (sufficient condition for q is p)
– Maria will find a good job unless she does not learn
discrete mathematics (q unless not p)

24
Common mistake for pq
Correct: p only if q
Mistake to think “q only if p”

25
Example
“If today is Friday, then 2+3=6”
– The statement is true every day except Friday even though
2+3=6 is false

26
Converse, contrapositive and Inverse

For conditional statement p q


– Converse: q p
– Contrapositive: ┐q  ┐ p
– Inverse: ┐p  ┐ q
Contrapositive and conditional statements are equivalent

27
Example1
If today is Sunday then it is holiday
Represent the above in converse, inverse, contrapostive
Let p: today is Sunday
q: it is holiday
Converse: q p
If it is holiday then today is Sunday
Inverse: ┐p  ┐ q
If today is not Sunday then it is not holiday
Contra positive: ┐q  ┐ p
If it is not holiday then today is not Sunday
Example2
If 5x-1=9 then x=2
Represent the above in converse, inverse, contrapostive
Let p: 5x-1=9
q: x=2
Converse: q p
If x=2 then 5x-1=9
Inverse: ┐p  ┐ q
If 5x-1҂9 then x ҂2
Contra positive: ┐q  ┐ p
If x ҂2 then 5x-1҂9
Biconditional statement

• Biconditional Statement: “p if and only if q”


• p  q is true when p, q have the same truth value. False otherwise
• Also known as bi-implications

30
Example
P: “you can take the flight”, q: “you buy a ticket”
P  q: “You can take the flight if and only if you buy a ticket”
– This statement is true
• If you buy a ticket and take the flight
• If you do not buy a ticket and you cannot take the flight

31
Truth table of compound
propositions

32
Precedence of logic operators

33
Bit operations

34
1.2 Translating English to logical
expressions
Why?
English is often ambiguous and translating sentences into
compound propositions removes the ambiguity
Using logical expressions, we can analyze them and determine
their truth values
We can use rules of inferences to reason about them

35
Example
“ You can access the internet from campus only if you are a
computer science major or you are not a freshman.
p : “You can access the internet from campus”
q : “You are a computer science major”
r : “You are freshmen”
p  ( q v ┐r )

36
System specification
Translating sentences in natural language into logical
expressions is an essential part of specifying both
hardware and software systems.
system specification should be consistent i.e they should
not contain conflicting requirements that could be used to
derive a contradiction..
Example: Express the specification “The automated reply
cannot be sent when the file system is full”

37
Example
1. Let p denote “The automated reply can be sent”
2. Let q denote “The file system is full”
The logical expression for the sentence “The automated reply
cannot be sent when the file system is full” is

38
Example
Determine whether these system specifications are consistent:
1. The diagnostic message is stored in the buffer or it is
retransmitted.
2. The diagnostic message is not stored in the buffer.
3. If the diagnostic message is stored in the buffer, then it is
retransmitted.

39
Example
Let p denote “The diagnostic message is stored in the buffer”
Let q denote “The diagnostic message is retransmitted”

The three specifications are

40
Example
If we add one more requirement “The diagnostic message is not
retransmitted”
The new specifications now are

This is inconsistent! No truth values of p and q will make all the above statements
true

41
1.3 Propositional equivalences
Replace a statement with another statement with the same truth
value
For efficiency (speed-up) or implementation purpose (e.g.,
circuit design)

42
Tautology and contradiction

• A compound proposition:
• Tautology: always true
• Contradiction: always false
• Contingency: neither a tautology nor a contradiction

43
Logical equivalence
p ≡ q (p q): the compound propositions p and q are logically
equivalent if p ↔ q is a tautology
Can use truth table to determine whether two propositions are
equivalent or not

44
Example
Show that ┐(p v q) and ┐p ˄ ┐ q are equivalent

45
p  q  p  q

p q p→q ┐p˅q

T T T T

T F F F
F T T T

F F T T

46
Example

47
De Morgan’s laws

48
Example
Express the negation of “Heather will go to the concert or Steve
will go to the concert”

Negation:
Heather will not go to the concert AND Steve will not go to the
concert.

49
De Morgan’s law: general form
The first example above is known as the De Morgan’s law

50
Logical equivalences

51
52
53
Constructing new logical
equivalences
Show ┐ (p → q) ≡ p ˄ ┐ q
┐ (p → q) ≡ ┐(┐p ˅ q)
≡ ┐(┐p) ˄ ┐q
≡ p ˄ ┐q

54
Constructing new logical
equivalences
Show ┐ (p ˅ (┐ p ˄ q) ) ≡ ┐ p ˄ ┐ q
┐ (p ˅ (┐ p ˄ q) ) ≡ ┐ p ˄ (┐(┐ p ˄ q))
≡ ┐ p ˄ (┐(┐ p) ˅ ┐q)
≡ ┐ p ˄ (p ˅ ┐q)
≡ (┐ p ˄ p ) ˅ (┐ p ˄ ┐q)
≡ F ˅ (┐ p ˄ ┐q)
≡ ┐ p ˄ ┐q

55
Show (p ˄ q) → (p ˅ q) is a Tautology
(p ˄ q) → (p ˅ q) ≡ ┐( p ˄ q) ˅ (p ˅ q)
≡( ┐p ˅ ┐ q) ˅ (p ˅ q)
≡ (┐ p ˅ p) ˅ (┐q ˅ q)
≡ T ˅T
≡ T

56
THANKS

You might also like