You are on page 1of 11

Program : B.

Tech
Subject Name: Discrete Structure
Subject Code: IT-302
Semester: 3rd
Downloaded from be.rgpvnotes.in

UNIT-3
Propositional Logic
The rules of mathematical logic specify methods of reasoning mathematical statements. Greek philosopher,
Aristotle, was the pioneer of logical reasoning. Logical reasoning provides the theoretical base for many areas
of mathematics and consequently computer science. It has many practical applications in computer science
like design of computing machines, artificial intelligence, definition of data structures for programming
languages etc.
Propositional Logic is concerned ith state e ts to hi h the t uth alues, t ue a d false , a e
assigned. The purpose is to analyze these statements either individually or in a composite manner.
Prepositional Logic – Definition
A proposition is a collection of declarative statements that has eithe a t uth alue "t ue o a t uth alue
"false". A propositional consists of propositional variables and connectives. We denote the propositional
variables by capital letters (A, B, etc). The connectives connect the propositional variables.
“o e e a ples of P opositio s a e gi e elo −
i. "Ma is Mo tal", it etu s t uth alue TRUE
ii. "12 + 9 = 3 – ", it etu s t uth alue FAL“E
The follo i g is ot a Propositio −
"A is less than 2". It is because unless we give a specific value of A, we cannot say whether the statement is
true or false.
Connectives
I p opositio al logi ge e all e use fi e o e ti es hi h a e −
i. OR ( )
ii. AND ( )
iii. Negation/ NOT (¬)
iv. Implication / if-the →
v. If and only if (⇔).
OR ( ) − The OR ope atio of t o p opositio s A a d B itte as A B) is true if at least any of the
p opositio al a ia le A o B is t ue. The t uth ta le is as follo s −
A B A B
True True True
True False True
False True True
False False False
Table 3.1
AND ( ) − The AND ope atio of t o p opositio s A a d B itte as A B ) is true if both the propositional
a ia le A a d B is t ue. The t uth ta le is as follo s −
A B A B
True True True
True False False
False True False
False False False
Table 3.2
Negation (¬) − The egatio of a p opositio A itte as ¬A) is false when A is true and is true when A is
false.The t uth ta le is as follo s −
A ¬A
True False

Page no: 1 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

False True
Table 3.3
Implication / if-the → − A i pli atio A→B is the p opositio if A, the B . It is false if A is t ue a d B is
false. The est ases a e t ue. The t uth ta le is as follo s −
A B A→B
True True True
True False False
False True True
False False True
Table 3.4
If and only if (⇔) − A⇔B- isbiconditional logical connective which is true when p and q are same, i.e. both are
false o oth a e t ue. The t uth ta le is as follo s −
A B A⇔B
True True True
True False False
False True False
False False True

Table 3.5
Tautologies - A Tautology is a formula which is always true for every value of its propositional variables.
E a ple − P o e [ A→B) A]→B is a tautology
The t uth ta le is as follo s −
A B A→B A→B A [ A→B A] → B
True True True True True
True False False False True
False True True False True
False False True False True
Table 3.6
As we can see every value of [(A→B) A]→B
is "True", it is a tautology.

Contradictions- A Contradiction is a formula which is always false for every value of its propositional
variables.
Example − Prove (A B) [(¬A) (¬B)] is a contradiction
The t uth ta le is as follo s −
A B A B ¬ A ¬ B (¬ A) ( ¬ B) (A B) [( ¬ A) (¬ B)]
True True True False False False False
True False True False True False False
False True True True False False False
False False False True True True False
Table 3.7
As we can see every value of (A B) [(¬A) (¬B ] is False , it is a o t adi tio .

Contingency- A Contingency is a formula which has both some true and some false values for every value of
its propositional variables.
Exa ple − Pro e A B) (¬A) a contingency

Page no: 2 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

The t uth ta le is as follo s −


A BA B ¬ A (A B) (¬ A)
True True
True False False
True False
True False False
False True
True True True
False False
False True False
Table 3.8
As we can see every value of (A B) (¬A has oth T ue a d False , it is a o ti ge .

Laws of Algebra of Propositions:


Identity:
pVp≡p pΛp≡p p→p≡T p↔p≡T
pVT≡T pΛT≡p p→T≡T p↔T≡p
pVF≡p pΛF≡F p → F ≡ ~p p ↔ F ≡ ~p
T→p≡p
F→p≡T
Commutative:
pV ≡ Vp pΛ ≡ Λp p→ ≠ →pp↔ ≡ ↔p
Complement:
p V ~p ≡ T p Λ ~p ≡ F p → ~p ≡ ~p p ↔ ~p ≡ F
~p → p ≡ p
Double Negation:
~ ~p ≡ p
Associative:
pV V ≡ pV V
pΛ Λ ≡ pΛ Λ
Distributive:
pV Λ ≡ pV Λ pV
pΛ V ≡ pΛ V pΛ
Absorbtion:
pV pΛ ≡p
pΛ pV ≡p
De Morga ’s:
~ p V ≡ ~p Λ ~
~ p Λ ≡ ~p V ~
Equivalence of Contrapositive:
p → ≡ ~ → ~p
Others:
p → ≡ ~p V
p↔ ≡ p→ Λ →p

Propositional Equivalences
T o state e ts X a d Y a e logi all e ui ale t if a of the follo i g t o o ditio s hold −
i. The truth tables of each statement have the same truth values.
ii. The bi-conditional statement X⇔Y
iii. is a tautology.
Example − Prove ¬(A B)and[(¬A) (¬B)] are equivalent
Testing by 1st method (Matching truth table)

Page no: 3 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

A B A B ¬ (A B) ¬ A ¬ B [(¬ A) (¬ B)]
True TrueTrue False False False False
True False
True False False True False
False TrueTrue False True False False
False False
False True True True True
Table 3.9
Here, we can see the truth values of ¬(A B)and[(¬A) (¬B)]
are same, hence the statements are equivalent.
Testing by 2nd method (Bi-conditionality)
A B ¬ (A B ) [(¬ A) (¬ B)] [¬ (A B)] ⇔ [(¬ A ) (¬ B)]
True True False False True
True False False False True
False True False False True
False False True True True
Table 3.10
As [¬(A B)]⇔[(¬A) (¬B)]
is a tautology, the statements are equivalent.

Inverse, Converse, and Contrapositive


1. Implication / if-the → is also alled a o ditio al state e t. It has t o pa ts −
i. Hypothesis, p
ii. Conclusion, q
As mentioned earlier, it is denoted as p→q
Example of Conditional Statement − If ou do ou ho e o k, ou ill ot e pu ished. He e, " ou do ou
homework" is the hypothesis, p, and "you will not be punished" is the conclusion, q.
1. Inverse − A i e se of the o ditio al state e t is the egatio of oth the h pothesis a d the
o lusio . If the state e t is If p, the , the i e se ill e If ot p, the ot . Thus the i e se
of p→qis ¬p→¬q
Example − The i e se of If ou do ou ho e o k, ou ill ot e pu ished is If ou do ot do ou
homework, you will be punished.
2. Converse − The o e se of the o ditio al state e t is o puted i te ha gi g the h pothesis
a d the o lusio . If the state e t is If p, the , the o e se ill e If , the p . The o e se
of p→qis q→p
Example − The o e se of "If ou do your homework, you will not be punished" is "If you will not be
pu ished, ou do ot do ou ho e o k .
3. Contrapositive − The o t apositi e of the o ditio al is o puted i te ha gi g the h pothesis
and the conclusion of the inverse statement. If the state e t is If p, the , the o t apositi e ill
e If ot , the ot p . The o t apositi e of p→qis ¬q→¬p
Example − The Co t apositi e of " If ou do ou ho e o k, ou ill ot e pu ished is "If ou a e ot
punished, then you do not do your home o k .

Duality Principle
Duality principle states that for any true statement, the dual statement obtained by interchanging unions into
intersections (and vice versa) and interchanging Universal set into Null set (and vice versa) is also true. If dual
of any statement is the statement itself, it is said self-dual statement.
Example − The dual of A∩B)∪C is (A∪B ∩C

Page no: 4 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

Predicate Logic- It deals with predicates, which are propositions containing variables.
Definition - A predicate is an expression of one or more variables defined on some specific domain. A
predicate with variables can be made a proposition by either assigning a value to the variable or by quantifying
the variable.
The following are some examples of predicates –
i. Let E(x, y) denote "x = y"
ii. Let X(a, b, c) denote "a + b + c = 0"
iii. Let M(x, y) denote "x is married to y"

Normal Forms
We a o e t a p opositio i t o o al fo s −
i. Conjunctive normal form
ii. Disjunctive normal form
i. Conjunctive Normal Form - A compound statement is in conjunctive normal form if it is obtained by
operating AND among variables (negation of variables included) connected with ORs. In terms of set
operations, it is a compound statement obtained by Intersection among variables connected with Unions.
Example - (A B) (A C) (B C D)
ii. Disjunctive Normal Form- A compound statement is in conjunctive normal form if it is obtained by
operating OR among variables (negation of variables included) connected with ANDs. In terms of set
operations, it is a compound statement obtained by Union among variables connected with Intersections.
Example - (A B) (A C) (B C D)

Well Formed Formula- Well Fo ed Fo ula ff is a p edi ate holdi g a of the follo i g −
i. All propositional constants and propositional variables are wffs
ii. If x is a variable and Y is a wff, ∀xYand∃xYare also wff
iii. Truth value and false values are wffs Each atomic formula is a wff
iv. All connectives connecting wffs are wffs
Quantifiers - The variable of predicates is quantified by quantifiers. There are two types of quantifier in
p edi ate logi − U i e sal Qua tifie a d E iste tial Qua tifie .
1. Universal Quantifier - Universal quantifier states that the statements within its scope are true for
every value of the specific variable. It is denoted by the symbol ∀.
∀xP(x) is read as for every value of x, P(x) is true.
Example − "Ma is o tal" a e t a sfo ed i to the p opositio al fo ∀xP(x)
where P(x) is the predicate which denotes x is mortal and the universe of discourse is all men.
2. Existential Quantifier - Existential quantifier states that the statements within its scope are true for
some values of the specific variable. It is denoted by the symbol ∃.
∃xP(x) is read as for some values of x, P(x) is true.
Example − "“o e people a e disho est" a e t a sfo ed i to the p opositio al fo ∃xP(x)
where P(x) is the predicate which denotes x is dishonest and the universe of discourse is some people.
3. Nested Quantifiers - If we use a quantifier that appears within the scope of another quantifier, it is
called nested quantifier.
Example
i. ∀ a∃bP(x,y) where P(a,b) denotes a+b=0
ii. ∀ a∀b∀cP(a,b,c) where P(a,b) denotes a+(b+c)=(a+b)+c
Note − ∀a∃bP(x,y ≠∃a∀bP(x,y)

Rules of Inference- To deduce new statements from the statements whose truth that we already know, Rules
of Inference are used.
● Mathematical logic is often used for logical proofs. Proofs are valid arguments that determine the truth

Page no: 5 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

values of mathematical statements.


● An argument is a sequence of statements. The last statement is the conclusion and all its preceding
state e ts a e alled p e ises o h pothesis . The s ol ∴ , (read therefore) is placed before the
conclusion. A valid argument is one where the conclusion follows from the truth values of the
premises.
● Rules of Inference provide the templates or guidelines for constructing valid arguments from the
statements that we already have.
Table of Rules of Inference
Rule of Inference Name Rule of Inference Name
1. Addition
If P is a premise, we can use Addiction rule to derive P Q
P∴P Q
Example
Let P e the p opositio , He studies e ha d is t ue
The efo e − "Eithe he studies e ha d O he is a e ad stude t." He e Q is the p opositio he is a e
bad stude t .
2. Conjunction
If P and Q are two premises, we can use Conjunction rule to derive P Q
PQ∴P Q
Example
Let P − He studies e ha d
Let Q − He is the est o i the lass
The efo e − "He studies e ha d a d he is the est o i the lass"
3. Simplification
If P Q is a premise, we can use Simplification rule to derive P.
P Q∴P
Example
"He studies very hard and he is the best boy in the class", P Q
The efo e − "He studies e ha d"
4. Modus Ponens
If P and P→Q are two premises, we can use Modus Ponens to derive Q.
P→QP∴Q
Example
"If you have a password, then you can log on to facebook", P→Q
"You ha e a pass o d", P The efo e − "You a log o to fa e ook"
5. Modus Tollens
If P→Qand ¬Q are two premises, we can use Modus Tollens to derive ¬P
P→Q¬Q∴¬P
Example
"If you have a password, then you can log on to facebook", P→Q
"You cannot log on to facebook", ¬Q
The efo e − "You do ot ha e a pass o d "
6. Disjunctive Syllogism
If ¬P and P Q are two premises, we can use Disjunctive Syllogism to derive Q.
¬PP Q∴Q
Example
"The ice cream is not vanilla flavored", ¬P
"The ice cream is either vanilla flavored or chocolate flavored", P Q

Page no: 6 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

The efo e − "The i e ea is ho olate fla o ed


7. Hypothetical Syllogism
If P→Q and Q→R are two premises, we can use Hypothetical Syllogism to derive P→R
P→QQ→R∴P→R
Example
"If it ai s, I shall ot go to s hool , P→Q
"If I don't go to school, I won't need to do homework", Q→R
The efo e − "If it ai s, I o 't eed to do ho e o k"
8. Constructive Dilemma
If (P→Q) (R→S) and P R are two premises, we can use constructive dilemma to derive Q S
(P→Q) (R→S)P R∴Q S
Example
If it ai s, I ill take a lea e , P→Q)
If it is hot outside, I ill go fo a sho e , R→S)
Eithe it ill ai o it is hot outside , P R
The efo e − "I ill take a leave or I will go for a shower"
9. Destructive Dilemma
If (P→Q) (R→S) and ¬Q ¬S are two premises, we can use destructive dilemma to derive P R
(P→Q) (R→S)¬Q ¬S∴P R
Example
If it ai s, I ill take a lea e , P→Q)
If it is hot outside, I ill go fo a sho e , R→S)
Eithe I ill ot take a lea e o I ill ot go fo a sho e , ¬Q ¬S
The efo e − "Eithe it ai s o it is hot outside"

Finite state machine :a finite state machine (sometimes called a finite state automaton) is a computation
model that can be implemented with hardware or software and can be used to simulate sequential logic and
some computer programs. Finite state automata generate regular languages. Finite state machines can be
used to model problems in many fields including mathematics, artificial intelligence, games, and linguistics.

Finite state machines as models of physical system equivalence machines:


Deterministic Finite-State Automata

A DFSA can be formally defined as A = Q, Σ, ∂, 0, F):


● Q, a finite set of states
● Σ, a fi ite alpha et of i put s ols
● q0 ∈ Q, an initial start state
● F ⊆ Q, a set of final states
● ∂ delta : Q Σ → Q, a t a sitio fu tio

We a defi e ∂ o o ds, ∂w, by using a recursive definition:


● ∂w : Q Σ* → Q a function of (state, word) to a state
● ∂w ,ε = i state , output state if o d is ε
● ∂w , a = ∂ ∂w(q,x),a)othe ise, use ∂ fo o e step a d e u se

For an automaton A, we can define the language of A:


● L(A) = {w∈Σ* : ∂w(q0,w) ∈ F }
● L (A is a su set of all o ds of fi ite le gth o e Σ, su h that the t a sitio fu tio ∂ w(q0,w)
produces a state in the set of final states (F).

Page no: 7 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

● Intuitively, if we think of the automaton as a graph structure, then the words in L(A) represent the
paths hi h e d i a fi al state. If e o ate ate the la els f o the edges i ea h su h path, e
derive a string w ∈L(A).

1. States are shown as circles;


2. the start state is indicated by the bold incoming arrow.
3. The next state function and output functions are shown using directed arrows from one state to
another. Each arrow is labeled with one element of I and one element of O.
4. If the machine is in some state s and the current input symbol is x, then we follow the arc labeled x/y
from s to a new state and produce output y.

Figure 3.1
Finite State Machines as Language Recognizers
Input = {0,1}
acceptingstate:A state is said to be an accepting state if its output is 1.
rejectingstate:A state is said to be an rejecting state if its output is 0.
An input sequence is said to be accepted by the finite state machine if it leads the machine from the initial
state to an accepting state. On the other hand, an input sequence is said to be rejected by the finite state
machine if it leads the machine from the initial state to an rejecting state.
finite state language
A language is said to be a finite state language if there is a finite state machine that accepts exactly all
sentences in the language.

Theorem Let L be a finite state language accepted by a finite state machine with N states. For any
se ue e α hose le gth is N o la ge i the la guage, α a e itte as u su h that is o e pt
and uviw is also in the language for i≧0, where vi denotes the concatenation of i copies of the sequence v.
(In other o ds, u , u , u ,u , … a e all i the la guage.

Proof:
Letα= a a a …aN, ithout loss of ge e alit .
Let sj0, sj1, sj2, …,sjN denote the states the machine visits, where s j0 is the initial state and sjN is an accepting
state.
Among the N+1 states sj0, sj1, sj2, …,sjN there are two of them that are the same. Suppose that is state s k, we
ealize that the se ue es u , u , u ,u , …, u I , … ill all lead the a hi e f o the i itial state
sj0 to the accepting state sjN.

Question :Design a DFA such that: L = {anbmcl | , ,l ≥ } Gi e : I put alpha et, Σ={a, , } La guage L =
{abc, aabc, abbc, abcc, ...}
Clearly the language is infinite because there is infinite number of strings.

Page no: 8 Follow us on facebook to get real-time updates from RGPV


Downloaded from be.rgpvnotes.in

Figure 3.2
The idea behind this approach is very simple, follow the steps below and you will understand.
1. Accept the smallest string 'abc' in the DFA that is four states will be made and state D will be made the
final state
2. Now what if input 'b'/'c' comes on state A then it should be rejected as 'b'/'c' cannot come before 'a'
3. At state B if 'a' comes then we can loop it as no given DFA property will be violated
4. At state B if 'c' comes then it should be rejected as 'c' cannot come before 'b'
5. At state C if 'b' comes then we will loop it
6. At state C if 'a' comes then it should be rejected as 'a' cannot come after 'b'
7. At state C if 'c' comes then it should flow to state D
8. At state D if 'c' comes then we will loop it
9. At state D if 'a'/'b' comes then it should be rejected as 'a'/'b' cannot come after 'c'
10. State E will be Dead state and it will be looped for 'a', 'b' and 'c'
Testing
1. Lets take one input string aaabbbcc
2. Scan string from left to right
3. First input is a, so from state A we will go to state B
4. Second input is a, so from state B we will go to state B itself
5. Third input is a, so from state B we will go to state B itself
6. Fourth input is b, so from state B we will go to state C
7. Fifth input is b, so from state C we will go to state C itself
8. Sixth input is b, so from state C we will go to state C itself
9. Seventh input is c, so from state C we will go to state D
10. Eight input is c, so from state C we will go to state C itself(final state)

Page no: 9 Follow us on facebook to get real-time updates from RGPV


We hope you find these notes useful.
You can get previous year question papers at
https://qp.rgpvnotes.in .

If you have any queries or you want to submit your


study notes please write us at
rgpvnotes.in@gmail.com

You might also like