0% found this document useful (0 votes)
164 views62 pages

#1 Logic

This document introduces the concepts of logic and propositional logic. It discusses how logic is used in mathematics, programming, and electronics. Propositional logic uses propositions that can be either true or false. Various logical operators like negation, conjunction, disjunction, implication, and biconditional are introduced and their truth tables are shown. Nested logical expressions and equivalent statements are also discussed. Logical concepts like tautologies, contradictions, and equivalence are defined.

Uploaded by

gamemaster421
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
164 views62 pages

#1 Logic

This document introduces the concepts of logic and propositional logic. It discusses how logic is used in mathematics, programming, and electronics. Propositional logic uses propositions that can be either true or false. Various logical operators like negation, conjunction, disjunction, implication, and biconditional are introduced and their truth tables are shown. Nested logical expressions and equivalent statements are also discussed. Logical concepts like tautologies, contradictions, and equivalence are defined.

Uploaded by

gamemaster421
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 62

Logic!

Logic
Mathematical Logic is a tool for working with complicated compound statements. It includes: A language for expressing them. A concise notation for writing them. A methodology for objectively reasoning about their truth or falsity.

Logic
Crucial for mathematical reasoning Important for program design Used for designing electronic circuitry Used in queries for databases & search engines.

Propositional Logic
(Propositional) Logic is a system based on propositions. propositions. A proposition is a (declarative) statement that is either true or false (not both, neither or somewhere in between). We say that the truth value of a proposition is either true (T) or false (F). (T (F Corresponds to 1 and 0 in digital circuits
4

The Statement/Proposition
Elephants are bigger than mice. Is this a statement? Is this a proposition? What is the truth value of the proposition? yes yes

true
5

The Statement/Proposition
520 < 111 Is this a statement? Is this a proposition? What is the truth value of the proposition? yes yes

false
6

The Statement/Proposition
y > 5 Is this a statement? Is this a proposition? yes no

Its truth value depends on the value of y, but this value is not specified. We call this type of statement a propositional function or open sentence. sentence.
7

The Statement/Proposition
Today is January 27 and 99 < 5. Is this a statement? Is this a proposition? What is the truth value of the proposition? yes yes

false
8

The Statement/Proposition
Please do not fall asleep. Is this a statement? Its a request. Is this a proposition? no no

Only statements can be propositions.


9

The Statement/Proposition
If the moon is made of cheese, then I will be rich. Is this a statement? Is this a proposition? What is the truth value of the proposition? yes yes

probably true
10

The Statement/Proposition
x < y if and only if y > x. Is this a statement? Is this a proposition? because its truth value does not depend on specific values of x and y. What is the truth value of the proposition? true
11

yes yes

Combining Propositions
As we have seen in the previous examples, one or more propositions can be combined proposition. to form a single compound proposition. We formalize this by denoting propositions with letters such as P, Q, R, S, and introducing several logical operators or logical connectives. connectives.
12

Logical Operators (Connectives)


We will examine the following logical operators: Negation Conjunction Disjunction Exclusive-or Exclusive Implication Biconditional (NOT, ) (AND, ) (OR, ) (XOR, ) (if then, p ) (if and only if,

Truth tables can be used to show how these operators can combine propositions to compound propositions.

13

Negation (NOT)
Unary Operator, Symbol: P true (T) false (F) P false (F) true (T)
14

Examples of Negation () operator


1) P : I have brown hair. P : I do not have brown hair. 2) P : It is cold. P : It is not cold. 3) P : 2 + 3 > 1 P:2+3<1
15

Conjunction (AND)
Binary Operator, Symbol:
P T T F F Q T F T F P Q T F F F
16

Examples of And () operator


1) P : I will have rice for lunch. Q : I will have chapati for dinner. P Q : I will have rice for lunch and chapati for dinner. 2) P : It is raining. Q : 3 < 5. P Q : It is raining and 3 < 5.
Note: A conjunction P1 P2 its Truth Table.

Pn of n propositions will have 2n rows in


17

Disjunction (OR)
Binary Operator, Symbol:
P T T F F Q T F T F P Q T T T F
18

Examples of OR () operator
1) P : My car has a bad engine. Q : My car has a bad carburetor. P Q : My car has a bad engine, or my car has a bad carburetor (or both). Note: P Q is TRUE means P is true, or Q is true, or both are true! So, this operation is also called inclusive or. or.

19

Exclusive Or (XOR)
Binary Operator, Symbol:
P T T F F Q T F T F P Q F T T F
20

Examples of XOR () operator


1) P : I will earn an A in this course. Q : I will drop this course. P Q : I will either earn an A in this course, or I will drop this course (but not both). Note: P Q is TRUE means that either P is true, or Q is true, but not both are true together! So, this operation is called exclusive or. or.

21

Implication (if then)


Binary Operator, Symbol: p
P T T F F Q T F T F PpQ T F T T
22

Examples of Implication (p) operator (p


P : You study hard. Q : You will get a good grade. P p Q : If you study hard, then you will get a good grade (else it could be go either way). So, if P is true then, then Q is true; but if P is not true then Q could be either true or false.

23

Implication Continue
P p Q is false only when P is true but Q is not true. P p Q does not say say that P causes Q. P p Q does not require that P or Q are ever true. Example: (1=0) p Elephant can fly TRUE

24

Implication Continue
(1=0) p Elephant can fly : TRUE!! Seems Wrong !! Well, there is discrepancy in between English Language and Mathematical Logic. In English, a sentence if P then Q usually really implicitly means: In all possible situations, if P then Q Q follows from P Q is implied by P This is not necessarily true for mathematical logic.
25

Implication Continue
(1=0)p (1=0)p Elephant can fly: If (1=0) then Elephant can fly : PpQ Pp

What about Elephant can not fly p (1=0) : If Elephant (1=0) Elephant can not fly then (1=0) : Q p P ? TRUE What is the relation between P p Q and Q p P ? They have the same meaning (truth table)!! PpQ Q p P (Converse) P p Q (Inverse) Q p P (Contrapositive)
26

Implication Continue
Truth table for P p Q, P p Q, Q p P, Qp P P T T F F Q T F T F P F F T T Q P p Q P p Q Qp P Q p P F T F T T F T T T T F T T T F T T F T T

27

More Examples of Implications


1) If this lecture ends, then the sun will rise tomorrow. True or False? 2) If Tuesday is a day of the week, then I am a penguin. True or False? 3) If 1 + 1 = 6, then Pratibha is President. True or False? 4) If moon is made of green cheese, then I am richer than Bill Gates. True or False?
28

Biconditional (if and only if)


Binary Operator, Symbol: m
P T T F F Q T F T F PmQ T F F T
29

Examples of Biconditional (m) operator


The biconditional P m Q states that P is true if and only if (iff) Q is true. P : He passes second semester. Q : He will be a student of third semester classes. P m Q : If, and only if, he passes second semester, he will be a student of third semester classes.

30

Biconditional Continue
P m Q true means that P and Q have the same truth value (either true or false).

Truth Table of m is exactly opposite of the truth Table of . (Thus (P m Q) means p(P Q).) P m Q does not imply that P and Q are true, or causes each other.

31

Propositional Operations: Truth Table Summary


P T T F F Q T F T F P F F T T PQ P Q P Q P pQ P m Q T F F F T T T F F T T F T F T T T F F T

32

Some Alternative Notations


Name Propositional Logic Boolean Algebra C/C++ (wordwise) C/C++ (Bitwise) Logic gates not and or xor implies iff

Pc ! ~

PQ && &

+ || |


!= ^

==

33

Nested Propositional Expressions


More than 2 propositions could form a new (meaningful) expression by adding proper parenthesis and operators. Examples: 1) P : I just saw my old friend. Q : He is grown. R : I have shrunk. P (Q R) : I just saw my old friend, and either he is grown or I have shrunk. Notes: 1) (PQ) R would mean something different.
2) P Q R would be ambiguous.
34

Examples Continue
2) P : It rained last night. Q : The sprinkler was on last night. R : The lawn was wet this morning. R P Q : Either the lawn wasnt wet this morning, or it rained last night, or the sprinkler was on last night. Note: By convention, takes precedence over both and . Thus, P Q means ( P) Q, but not (P Q). (
35

Nested Expressions
Truth Table
P T T F F Q T F T F P F F T T Q F T F T
(P)(Q) P)

F T T T
36

Nested Expressions
Truth Table
P T T F F Q T F T F PQ (PQ) (P)(Q) P) T F F F F T T T F T T T
37

Exercises
To take discrete mathematics, you must have taken calculus or a course in computer science. When you buy a new car from Kiron Motor Company, you get Rs.2000 back in cash or a 2% car loan. School is closed if more than 6 inches of rain falls or if the wind chill is below 2oc.

38

Exercises
To take discrete mathematics, you must have taken calculus or a course in computer science. P: take discrete mathematics Q: take calculus R: take a course in computer science

P p Q R

39

Exercises
When you buy a new car from Kiron Motor Company, you get Rs. 2000 back in cash or a 2% car loan.
P: buy a car from Kiron Motor Company Q: get Rs. 2000 cash back R: get a 2% car loan

Pp Q

R
40

Exercises
School is closed if more than 6 inches of rain falls or if the wind chill is below 2oc.
P: School is closed Q: 6 inches of rain falls R: wind chill is below 2oc

QRpP Precedence among operators:

, , , p, m
41

Equivalent Statements
P Q (PQ) (P)(Q) (PQ)m(P)(Q) P) Q)m P)

T T F F

T F T F

F T T T

F T T T

T T T T

The statements (PQ) and (P) (Q) are logically ( equivalent, equivalent, since they have the same truth table, or put it in another way, (PQ) m(P) (Q) is always true.
42

Tautologies and Contradictions


A tautology is a statement that is always true. Examples: R(R) (PQ) m (P)( Q) P) A contradiction is a statement that is always false. Examples: R(R) ((P Q) m (P) (Q)) The negation of any tautology is a contradiction, and the negation of any contradiction is a tautology.
43

Equivalence
Definition: two propositional statements S1 and S2 are said to be (logically) equivalent, denoted S1 | S2 if
They have the same truth table, or S1 S2 is a tautology

Equivalence can be established by


Constructing truth tables Using equivalence laws

44

Logical Equivalence
Equivalence laws
Identity laws, Domination laws, Idempotent laws, Double negation law, Negation Laws, Commutative laws, Associative laws, P T | P, and P F | P P T | T, and P F | F P P | P, and P P | P ( P) | P P P | T, and P P | F P Q | Q P, and P Q | Q P P (Q R) | (P Q) R, P (Q R) | (P Q) R P (Q R) | (P Q) (P R), P (Q R) | (P Q) (P R) (P Q) | ( P) ( Q) (P Q) | ( P) ( Q) 45

Distributive laws, De Morgans laws,

Logical Equivalence (Implications)


PpQ|PQ PpQ|QpP PQ|PpQ P Q | (P p Q) (P p Q) | P Q (P p Q) (P p R) | P p (Q R) (P p R) (Q p R) | (P Q) p R (P p Q) (P p R) | P p (Q R) (P p R) (Q p R) | (P Q) p R
46

Logical Equivalence (Biconditionals)


P m Q | (P p Q) (Q p P) PmQ|PmQ P m Q | (P Q) ( P Q) (P m Q) | P m Q

47

Propositional Functions & Predicates


Propositional function (open sentence): statement involving one or more variables, e.g.: x-3 > 5. xLet us call this propositional function P(x), variable. where P is the predicate and x is the variable. What is the truth value of P(2) ? false What is the truth value of P(8) ? false What is the truth value of P(9) ? true
When a variable is given a value, it is said to be instantiated Truth value depends on value of variable
48

Propositional Functions
Let us consider the propositional function Q(x, y, z) defined as: x + y = z. Here, Q is the predicate and x, y, and z are the variables. variables. true What is the truth value of Q(2, 3, 5) ? What is the truth value of Q(0, 1, 2) ? false What is the truth value of Q(9, -9, 0) ? true A propositional function (predicate) becomes a instantiated. proposition when all its variables are instantiated.
49

Propositional Functions
Other examples of propositional functions Person(x), which is true if x is a person Person(Sushruta) = T Person(dolly-thePerson(dolly-the-sheep) = F ICTCourse(x), which is true if x is an ICT course ICTCourse(Communication) = T ICTCourse(DIM) = F

50

Universal Quantification
Let P(x) be a predicate (propositional function). Universally quantified sentence: sentence: For all x in the universe of discourse P(x) is true. Using the universal quantifier : x P(x) for all x P(x) or for every x P(x) (Note: x P(x) is either true or false, so it is a proposition, not a propositional function.)
51

Universal Quantification
Example: Let the universe of discourse be all people
S(x): x is a UGICT student. G(x): x is a genius.

What does x (S(x) p G(x)) mean ? If x is a UGICT student, then x is a genius. or All UGICT students are geniuses. If the universe of discourse is all UGICT students, then the same statement can be written as
x G(x)
52

Existential Quantification
Existentially quantified sentence: sentence: There exists an x in the universe of discourse for which P(x) is true. Using the existential quantifier : x P(x) There is an x such that P(x). There is at least one x such that P(x). (Note: x P(x) is either true or false, so it is a proposition, but not a propositional function.)

53

Existential Quantification
Example: P(x): x is a DAIICT professor. G(x): x is a genius. What does x (P(x) G(x)) mean ? There is an x such that x is a DAIICT professor and x is a genius. or At least one DAIICT professor is a genius.
54

Quantification
Another example: Let the universe of discourse be the real numbers. What does xy (x + y = 320) mean ? For every x there exists a y so that x + y = 320. Is it true? Is it true for the natural numbers? yes no
55

Disproof by Counterexample
A counterexample to x P(x) is an object c so that P(c) is false. Statements such as x (P(x) p Q(x)) can be disproved by simply providing a counterexample. Statement: All birds can fly. Disproved by counterexample: Penguin.

56

Negation of Quantifiers
Negation True Flase P(x) is true for every x There is an x for which P(x) is true (x P(x)) There is an x for which P(x) is false (x P(x)) For every x, P(x) is false

(x P(x)) is logically equivalent to x (P(x)). ( (x P(x)) is logically equivalent to x (P(x)). ( This is de Morgans law for quantifiers
57

Negation
Examples Not all roses are red
x (Rose(x) p Red(x)) x (Rose(x) Red(x))

Nobody is perfect
x (Person(x) Perfect(x)) x (Person(x) p Perfect(x))

58

Nested Quantifier
A predicate can have more than one variables.
S(x, y, z): z is the sum of x and y F(x, y): x and y are friends

We can quantify individual variables in different ways


x, y, z (S(x, y, z) p (x <= z y <= z)) x y z (F(x, y) F(x, z) (y != z) p F(y, z))

59

Nested Quantifier
Exercise: translate the following English sentence into logical expression
There is a rational number in between every pair of distinct rational numbers

Use predicate Q(x), which is true when x Q(x), is a rational number


x,y (Q(x) Q (y) (x < y) p (Q u (Q(u) (x < u) (u < y)))
60

Nested Quantifier
Exercise: translate the following English sentence into logical expression
If a person is female and is a parent, then this person is someones mother Use predicate P(x): x is parent, F(x): x is female parent, and M(x,y): x is the Mother of y. x, (F(x) P(x)) p y M(x,y). or x y, ((F(x) P(x)) p M(x,y)).

61

Quantification of Two Variables


Statement
x y P(x,y) y x P(y,x) x y P(x,y) x y P(x,y) x y P(x,y) y x P(y,x)

True P(x,y) is true for every pair x, y. For every x there is a y for which P(x,y) is true.

False There is a pair x, y for which P(x,y) is false. There is an x such that P(x,y) is false for every y.

There is an x for which For every x there is a y P(x,y) is true for every y. for which P(x,y) is false. There is a pair x, y for which P(x,y) is true. P(x,y) is false for every pair x, y.

62

You might also like