#1 Logic
#1 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
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
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
Conjunction (AND)
Binary Operator, Symbol:
P T T F F Q T F T F P Q T F F F
16
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
21
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
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
32
Pc ! ~
PQ && &
+ || |
!= ^
==
33
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
, , , 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
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
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
47
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
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
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
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