Professional Documents
Culture Documents
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
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
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)
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.
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
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
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.
● 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).
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.
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)