Escolar Documentos
Profissional Documentos
Cultura Documentos
Logic is found to be extremely useful in decision taking problems. In computer science and engineering, knowledge of logic is essential in in the following field: Analysis of algorithms and implementation Development of algorithms into a structured program in a programming language. A material of logic theory forms a basis in theoretical computer science such as Artificial Intelligence, Fuzzy logic, functioning of expert systems etc. Many times while working on a project after the beginning steps, we always have a doubt regarding whether the direction followed is right or wrong? Are we doing the job correctly? Whether the decisions taken are correct or incorrect etc? It is here logic plays an important role; using which one can solve a problem with lot of confidence and satisfaction. remarks, the next sections introduce formal symbolic logic. Basic Terminologies of logic: A Proposition is a declarative sentence written in some language, usually English, which is either true or false, but not both (i.e. true and false) at the same time. It is also referred as a simple statement or primitive proposition or an atomic statement. A proposition is denoted by using lower case letters such as p, q, r, s etc. Every proposition has exactly one of the two truth values; either true or false. When it is true, the same is assigned a symbol T or 1. If the primitive statement is false, it is assigned the symbol F or 0. In view of this, a proposition may be defined as a pair either (p, T) or (p, F). This situation may be compared to what we discussed earlier in set theory. It is seen that with respect to a set A and an element x, there are only two options; either x is an element of A or x need not be an element of A. There too we used the numbers 1 and 0 to describe the situation. The following are examples of propositions: p: Dr. Manmohan Singh is the president of India. q: Mumbai is the financial capital of India r: Bangalore is the silicon valley of India. s: 3+3=5 With these few
t: Dr. Abdul Kalam was awarded Bharath Rathna What about the following? x+3 is an integer. Please come in! Are u alright? Complete work today itself What are you doing? What a beautiful evening!
These are not considered as propositions. Because, x + 3 is an integer cannot be a proposition, as x is not specified. A statement of this kind is called an open statement. the statement gets a meaning only when x is assigned a value chosen from the universe of discourse of the problem considered. Others are either commands, or enquiries, or exclamatory sentences. These are not referred to as non-propositions. Discussion of various logical connectives Negation: Let p be a proposition. It is not the case that p is called as negation of the p.
Simply, it is NOT p . This is denoted by the symbol p . This situation can well be explained by using a truth table which is shown below:
p T F p F T p 1 0 p 0 1
Disjunction or logical OR: Let p and q be simple propositions. A proposition obtained by combining p and q using logical OR is called p disjunction q . It is denoted by p q . The truth value of p q is false only when both
p and q are false, otherwise, p q is a true
T T F F
T F T F
T T T F
Note: Logical operator is similar to the union operator in the case of set theory. Conjunction or logical AND:
Let p and q be simple propositions. A proposition obtained by combining p and q using logical AND is called p conjunction q . It is denoted by p q . The truth value of p q is true only when both
p and q are true otherwise p q
is a false proposition.
The same is
T T F F
T F T F
T F F F
Note: Logical operator is similar to the intersection operator in the case of set theory. Also, logical OR and logical AND have dual characteristics. Thus, conjunction and disjunction are examples of dual operators. One sided implication or logical IMPLICATION or IF THEN : Let p and q be simple propositions. A proposition obtained by combining p and q using logical connective, namely, one sided IMPLICATION is called p implies q . It is denoted by
p q . The truth value of p q is false only when p is true but q is a false proposition. In
all other instances, p q is a true statement. The truth table is given below.
p q
p q
T F T T
T T F F Few examples:
T F T F
If 3+3=7, then Sunday is a Christmas is a holiday. If 3+2 = 5, then sun raises in the east. If tomorrow is Monday, then yesterday was Saturday. If 32 7 = 23, then 5 + 6 = 9. 1. if p then q
2. p is sufficient for q 3. q is necessary for p 4. p only if q Bi-conditional or two sided implication OR IF AND ONLY IF or IFF: Let p and q be two simple propositions. denoted by the symbol p
p Bi-conditional q
is a compound proposition
q . he truth value of p
assigned the same truth value; otherwise, its truth value is false.
p q
T T F F
T F T F
T F T F
Note: Here, p is necessary and also sufficient for q. p bi-conditional q is to be read as p if and only if q.
Exclusive logical OR: Consider two propositions, say, p and q . Then p exclusive or
q is a compound proposition whose true value is false when both
truth values. Otherwise, the truth value is true. It is denoted by pq . The truth table is given below.
p q
pq
F T T F
T T F F
T F T F
Note: This logical operator is similar to the symmetric difference operation for sets.
p or q , denoted by ( p q) or by ( p q) .
( p q) : p - q
F T T T
pq
( p q) : p - q :
F F F T
T T F F
T F T F
T F F F
T T T F
Note: It may be noted each logical variable has two possible truth value assignments; True or False. Thus, if a statement formula contains n logical variables, then there are 2 n choices. Hence, the truth table of the formula will contain 2 n rows. What is meant by Tautology?
A : A( p1, p2, p3, . . . pk , ,,, ,
to be true, then A is called a tautology, or as universally accepted formula, or as universally valid formula, Thus, if a statement formula A is always true, then it said to be a tautology. Suppose, the truth value of A is always false, then it is called an absurdity, or contradiction, or universally invalid formula. On the other hand, if the truth value of A is some times true and at others false, then it is called contingency. Illustrative examples: By constructing the truth table of the following, determine which one is a tautology? Which one is a contradiction? Which is one a contingency?
1.
( p q)
(p q ) (q p)
2. (p q ) 3.
4. 5.
[p (p q)] q
((p q ) q ) p
(( p q) (q r)) ( p r)
(p q )
p
A: p q
B : p q
T T F F
T F T F
T F T T
F F T T
T F T T
T T T T
Therefore, ( p q)
(p q) is a Tautology
(p q )
p
(q p)
q
A: p q
B : q p
T T F F
T F T F
T F T T
F F T T
F T F T
T F T T
T T T T
As A : p q and B : q p have same set of truth values, therefore, p q and q p are logically equivalent to each other. Therefore, if a situation demands, the formula may well be replaced by q p . Solution to problem number 4:
p q
p q
T F T T
q
F T F T
A:
( p q) q
F F F T
A p
T T F F
T F T F
F F T T
T T T T
Since, ((p q ) q ) p is a tautology, and Thus, ((p q ) q ) p is a tautology. Logically equivalent statements Two statement formulas A and B are said to be logically equivalent, whenever A
B is a
tautology. Equivalently, if A and B have same set of truth values for each of the truth value assignments to the components of A and B. We denote this by A B . By constructing truth table, determine whether the following are logically equivalent? 1.
pq and [( p q ) (p q )] ,
2. (p q ) ( p ( p q )) and p q 3. ( p - q ) and (p q ) 4.
p (q r )) and ( p q ) r )
Solution of Problem No. 1. Consider the following truth table showing truth values of both the formulas
p q
pq
F T T F
q
F T F T
A : p q
B : p q
A B
F T T F
T T F F
T F T F
F F T T
F T F F
F F T F
From the table, it is clear that pq and [( p q ) (p q )] are logically equivalent. Solution of Problem Number 3: Consider the following truth table
p q pq
( p q ) : ( p - q )
( p - q )
q
F T F T
p q
(p q) : p q
T T F F
T F T F
T F F F
F T T T
T F F F
F F T T
F T T T
T F F F
From the above table, it follows that ( p - q ) and (p q ) are logically equivalent.
Solution: (a ) r q (b) p q
(c)
( s r) q
(a) For practicing her serve daily is a sufficient condition for Ms. Sania Mirza to have a good chance of winning the Australian Open tennis tournament. (b) Fix my air-conditioner or I wont pay the rent. (c) Manavi will be allowed to sit on Mohans motor bike only if she wears her helmet.
Solution :( a) If Ms. Sania Mirza practices her serve daily, then she will have a good chance of
winning the tennis tournament. (b) If you do not fix my air-conditioner, then I shall not pay the rent. (c) If Manavi is to be allowed on Mohans motor bike, then she must wear her helmet
Determine all truth value assignment, if any, for the primitive statements p, q, r , s, t that make each of the following statements false.
(a) [( p q) r ] ( s t )
(b) [( p q) r ] ( st )
Solution: For (a), the implication is given to be a false one, therefore, we must have ( p q ) r
as true, and s t as false. Thus, truth values of these primitive statements are: Primitive statements Truth values
p q
r
s
F
(b) The implication is given to be a false; we must have ( p q ) r as true and st as false. Thus, truth values of these primitive statements are: Primitive statements Truth values
p q r
s
T F
T T
T T
T T
T F
If statement q has the truth value 1, determine all truth value assignments for the primitive statements p, r, and s for which the truth value of (q [(p r ) s ]) [s (r q )] is 1. Solution: We shall setup A : (q [(p r ) s ]), B :[s (r q )] . Note that we are given
that A B is true (i.e. 1), therefore, it follows that both A and B are true statements. It is given that q has the truth value 1, it is clear that truth value of (p r ) s is 1, otherwise, the implication becomes false, which is not true actually. From this we infer that p r and s
are true statements. Thus, truth value of is true, so it follows that being true, w must
as
false.
Hence,
s
F
In the following program segment, I, j, m, and n are integer variables. The values of m and
n are supplied by the user earlier in the execution of the total program. for i := 1 to m do for j := 1 to n do if i j then pr int i * j How many times the print statement in the segment is executed when
(a ) m = 10, n = 10 (b) m = 20, n = 20 (c ) m = 10, n = 20 (d ) m = 20, n = 10
Solution: (a) For m = 10, n = 10, print statement will be executed only for 90 times. (b) For m = 20, n = 20, print statement will be executed only for 380 times. (c) For m = 10, n = 20, print statement will be executed only for 190 times. (d) For m = 20, n = 10, print statement will be executed only for 180 times
Negate and express the following statements in smooth English. (c) If Harold passes his C++ course and finishes his data structures project, then he will graduate at the end of semester. Solution: let us set up p: Harold passes C++ course, q: Harold finishes his data structures project, r: Harold becomes a graduate at the end of semester. Symbolically, the given statement may be written as ( p q) r . The negation of this statement is
(( p q ) r )
( p q) r , since A B A B
obtain
( p q) r
. Thus, the negated statement in English is Harold passes C++ course and
Harold finishes his data structures project but fails to graduate at the end of semester.
Concept of Duality in logic: Given a statement formula involving a number of primitive statements and several logical connectives, its dual may be obtained just by replacing conjunction
()
by disjunction ()
and vice versa, not disturbing other logical connectives. If the formula contains special symbols like T or F, then these are to be replaced by F and T respectively. Write the dual of the following: (a ) q p, (b) p ( q r ) , (c) p q Solution: Consider (a ) q p q p , therefore, its dual is q p . Consider (b) p ( q r ) p ( q r ) , therefore, the respective dual is p ( q r ) . Consider (c) p q Thus, the dual is
( p q) (q p) (p q) ( q p) .
( p q) ( q p) .
For the statement p q , q p is called the converse statement. For the statement p q , p q is called the inverse statement. For the statement p q , q p is called the contra-positive statement
Write the converse, inverse and contra -positive of the statement If today is a labor day, then tomorrow is Tuesday. Solution: The converse statement is If tomorrow is Tuesday, then today is Labor Day . The inverse statement is If today is not Labor Day, then tomorrow is not Tuesday. The contra-positive statement is If tomorrow is not Tuesday, then today is not Labor Day
( p q) r
p ( q r ) (Associative law)
( p q) r
p ( q r ) (Associative law) .
With respect to combination of conjunction operator i.e. logical AND operator disjunction operator i.e. logical OR
()
and
() ,
( p q) p q (De - Morgan law) ( p q) p q (De - Morgan law) ( p) p (double negation law) Therefore, one can claim that ( P , , , ) is a discrete structure.
Simplify [[( p q) r ] q] using laws of logic only. Also, state the law used in the derivation.
Solution:
We shall use De-Morgan law, Double negation law, and Associative law and Consider
( ) p q) q r ) ((
But
(( p q) q)
that k premises implies the conclusion C whenever ( H1 H 2 H 3 . . . H k ) C is a tautology. Symbolically, we describe it as ( H1 H 2 H 3 . . . H k ) C and read it as
(H
H1 : p q
H2 : q r
H1 H 2
C:p r
(H
H2 ) C
T T T
T T T
T T F
T F T
T T F
T F T
T F F
T F T
F T F F F
Since
T F T F F
T F F T F
T F T T T
T T F T T
T F F T T
T F T T T
T T T T T
(H
argument.
Determine whether the following argument is logically valid? H1: If I try hard and I have talent, then I will become a musician. H2: If I become a musician then I will be happy. H3: hard or I do not have talent. I have not become happy. Therefore, I did not try
Solution:
First we shall set up the following simple statements, namely, p : I try hard , q : I have talent ,
r : I become a musician and s : I became happy .
( p q) r ,
1
(H
H 2 H 3 ) C or whether ( H1 H 2 H 3 ) C a tautology?
Observe that this problem involves 4 logical variables. Therefore, truth table approach may not be proper as it is required to construct a table of 16 rows. This is not feasible, thus, there is a necessity to develop alternate strategies. With this in view, we shall now introduce rules of inference theory.
Rule 1: A given premise (i.e. a statement which is given to be true in the problem can be
used at any stage during the argument.
H : A i.e. A is true.
Rule 4: Modus ponens: Whenever p is true, p implying q is true, then q is certainly true.
Symbolically it is given as p, p q q . is a tautology. We can verify that
( p p q) q
q, p q p
One
can
verify
that
q ( p q) p is a tautology.
p r
( p r) .
( p q) p p ( p q) .
Now, we shall use the rules of inference theory. Consider the premises H1 and H2, i.e.
( p q) r and H : r s . Applying the law of syllogism, we obtain R1 : ( p q) s . Now consider R1 : ( p q) s and H : s ; using the law of Modus Tollens, we should get R2 : ( p q) . But it is known that ( p q) p q . Hence, argument is logically
H1 :
2 3
valid.
Determine whether the following argument is valid? H1: If Haripriya gets the supervisor position and works hard, then she gets a raise. H2: If she gets a raise, then she will buy a new car. H3: She has not purchased a new car. Conclusion: Either Haripriya did not get the supervisors position or she did not work hard Solution:
First we shall set up p: Haripriya gets the supervisors position. q: Haripriya works hard. r: She gets the raise. s: She purchase a new car. Then, then given premises can be written in symbolic form as H1 : ( p q) r , H2 : r s, H3 : s C : p q . Consider the premises H3 and H2, namely, H2 : r s and H3 : s . Applying the rule of Modus Tollens, we obtain the result
R1: r .
Now consider the premise H1 and the result just obtained R1, viz.,
Determine whether the following argument is valid? If the band could not play rock music or the refreshments were not delivered on time, then the New Years party would have been cancelled and Anita would have been angry. If the party were cancelled, then refunds would have had to be made. No refunds were made. Therefore, the band could play rock music. Solution: First we shall form the following primitive statements:
p : The band could play rock music, q : The refreshments were delivered on time r : New year party is cancelled, s : Anitha has become angry , t : Refunds had to be made
( H 1 H 2 H 3)
is a tautology?
As 5 parameters are
involved in this problem, we shall use the rules of inference theory. Consider the premises H3 and H2, namely, H2 : r t and H3 : t . Using Modus Tollens here, we will get the result that R1 : r . Equivalently, we have got that negation of r is true. Therefore, we must have that truth value of r as false. Due to this, it is clear that truth value of
From
here, it follows that truth value of (p q ) is false. But this is possible only when both
p and q are false. Thus, we obtain that truth value of p and q as true. Hence, given
H1 : p ( r s) , H2 : p q, H3 : q ( r s) , H 4 : r ( t u) , H 5 : p t
imply the conclusion C : u ? Consider
H5 : pt .
Argument:
and H3, namely, H2 : p q , H3 : q ( r s) , using the law of syllogism, we get the result
r ( t u) is true.
to conclude is truth value of u is true. Hence, the given argument is logically valid.
Solution:
Note that this problem is based on conditional proof. However, nothing is given about the nature of the primitive proposition, q . Thus, we shall introduce an additional premise namely, H5 : q i.e. q is a true proposition. Consider the premises H3 and H5 i.e. q and q ( u s) , applying the rule of Modus Ponens, we get the result R1 : ( u s) . Using the law of conjunction we obtain R2: u and s i.e. both u and s are true statements. Now using the result R2 and the premise H1, i.e.
R2: u, H1 : u r and the rule of Modus Ponens, we will get
R3 : r . As r
and s are true propositions, r s is a true statement. Using this and we Using get
( p t)
H2 : ( r s ) ( p t )
is
true
statement.
We
know
that p t t p t p .
H4: t here, and applying once again rule of Modus Pones, we should get that p is a
Thus,
n 2 is odd . To prove the converse, we shall give an indirect proof. To begin with let
n 2 be an odd integer. To prove that n is odd. Suppose on the contrary that let n be an even
( )
this is against our hypothesis that n 2 is odd. Hence, we conclude that n is an odd integer.
Prove that if
is
odd,
otherwise
3m + 2 = 3 ( 2k ) + 2 = 6k + 2 = 2( 3k + 1) , an even integer. this is impossible as it is given that 3m + 2 is an odd integer. Hence our assumption that m is even is wrong and so m must be an
odd integer.
To prove that
31n +12 = 31( 2k +1) +12 = 62k + 43 = 62k + 42 +1 = 2(31k + 21) +1 = 2m +1 where m = 31k + 21 is an odd integer which is impossible as we ourselves had
assumed that n is even. Hence, n must be an even integer.
Further, rules of inference theory were introduced using which problems based on logical arguments were examined. Now we shall initiate a discussion on predicates and quantifiers. Before understanding these, consider the following statements, Dog is an animal Cat is an animal Elephant is an animal Tiger is an animal Lion is an animal Deer is an animal Horse is an animal and the list go on Observe that all these statements are about individuals which are animals, so to study these; we require different symbols to denote these animals. But even the usage of different symbols, does not show the common property of the symbols, that each symbol denotes an animal. Suppose if we want to describe all the animals of the universe, then certainly a large number of symbols are necessary. To deal with a situation of this type, it is appropriate to develop a mechanism using which it must be possible represent all the common feature of the objects. The following section is devoted to the same. First we introduce a symbol to denote the phrase is an animal and secondly, a technique to joint it with a symbol representing an animal, then we are done as this single expression will speak about all the individuals which are animals. Here, the part is an animal is called as predicate. Usually, a predicate is represented by using upper case letters and lower case letters are considered for the objects associated with a predicate. Thus, let us consider A : is an animal then all objects which are animals may be expressed as
A( x ) where x is a variable to be chosen from the universe of discourse, namely, A( x )
predicate, . Since only one variable is involved here, A( x ) is said to be 1 place predicate function or as an open statement of a single variable. Similarly 2 place, 3 place predicates can be introduced. The study of predicate functions constitutes predicate calculus. Thus, it is clear that all the topics discussed under fundamentals of logic can be extended to predicates calculus. Therefore, one may combine the open statements using the logical
connectives, one can extend the definitions like logical equivalence, tautology etc to these. Please remember that the set of all objects is called as universe of discourse or just universe.
A note on Quantifiers
In a practical situation, we come across a number of quantified statements like Live lectures through EDUSAT programme is open for all engineering college students in Karnataka A vehicle having Karnataka state permit is permitted to move on any road in the state. There are some bad boys in a class room. Some students never follow Discrete Mathematics course whoever teaches this course. There is at least one student in some engineering watching this programme coming live from VTU studio, Bangalore. Pythagoras Theorem holds well for all right angled triangles and the list go on.
Statements shown in previous slides can be expressed symbolically using quantifiers. There are two types of quantifiers:
2. Existential Quantifier: There are statements which are true only under circumstances. These
statements may be symbolically expressed in terms of existential quantifier, denoted by $ . Consider an open statement of the form q ( x ) . Suppose that this statement is true only for some
values of x . This may be symbolically written as $ x q ( x ) . Note: An open statement of the form q ( x ) gets A meaning only when x is replaced by a proper value from the universe or universe of discourse, denoted by U .
Examples: Examples: Consider universe of discourse as the set of all days of a week. Then U =
{Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday}. Consider the statement
p( x ) : x is a holiday . It is known that there is a day in a week which is declared as a general
Another example; Take the universe as the set of all flowers and consider the statement, Flowers are beautiful. To write this statement in symbolic form, we shall set up .
f ( x ) : x is a flower , then above may be written symbolically as " x f ( x ) .
$ q( x ) will take the truth value false, only when for all values of x the statement q ( x ) is false.
[ p( x) q( x)] [$ x p( x) $ x q( x)] $ x [ p( x ) q( x )] [$ x p( x ) $ x q( x )] " x [ p( x ) q( x )] [" x p( x ) " x q( x )] [" x p( x) " x q( x)] " x [ p( x) q( x)]
$x
Also, we have the following results to negate the statements with one quantifier:
Tutorial on Quantifiers: For the universe of integers, let p( x ), q ( x ), r ( x ), s ( x ), t ( x ) be the following open statements.
Write the following statements in symbolic form: (i) (ii) (iii) (iv) (v) (vi) At least one integer is even . There exists a positive integer that is even. If x is even, then x is not divisibly by 5. No even integer is divisible by 5. There exists an even integer divisible by 5. If x is even and x is a perfect square, then
x is divisibly by 4.
Solution: i)
$ x q( x ) (ii ) $ x
(iv) " x [q ( x ) t ( x )] ( v)
Translate each of these statements into logical expressions using predicates, quantifiers and logical connectives: (i) (ii) (iii) (iv) Some students do not follow the rules. Some students are very serious. No student can keep a secret. There is some in this class who is very intelligent
Solution: Let us consider the universe as the set of all students of a college. First we shall set up the following primitive statements p( x ) : x follows the rules. q ( x ) : x is a very serious person. r ( x ) : x can keep secret. s ( x ) : x is very intelligent. Solution: (i )
$ x p( x ), (ii) $ x q ( x ), (iii ) " x r ( x ). (iv) $ x s( x )
For the universe of all integers, determine the truth or falsity of each of the following statements. If a statement is false, give a counter example. p( x ) : x 2 - 8 x + 15 = 0, q ( x ) : x is odd , r ( x ) : x > 0.
(a ) " x
d)
$x
x
[ p( x) q( x)] ( p( x ) q ( x )) r ( x )
( g) $ x p( x ) ( q ( x ) r ( x ))
( x - 3) ( x - 5) = 0 .
x = 3, x = 5. as both the roots are odd, it is clear that statement (a) is true.
According to statement (b) if x is an odd integer, then it is a solution of the quadratic equation
x 2 - 8 x + 15 = 0 .
quadratic equation. (c) The English version of this statement is that there is a solution of
x 2 - 8 x + 15 = 0 which is odd. As the roots are 3 and 5, which are odd, therefore, (c) and (d) are
both true statements. According to statement (e), there is a positive integer which is also a root of the quadratic equation x 2 - 8 x + 15 = 0 . This is true because x = 3 a positive integer and is a root. Statements (f) and (g) are both true.