Download Intro to Logic - CSE-IITM

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Propositional calculus wikipedia , lookup

Analytic–synthetic distinction wikipedia , lookup

Truth-bearer wikipedia , lookup

Principia Mathematica wikipedia , lookup

Transcript
Introduction to Logic
Why study Logic?
I
Understand meaning of mathematical sentences.
I
Develop the building blocks for mathematical reasoning.
I
Write correct proofs for mathematical statements.
I
Identify buggy proofs.
I
Because it is fun!
Why study Logic?
I
Understand meaning of mathematical sentences.
I
Develop the building blocks for mathematical reasoning.
I
Write correct proofs for mathematical statements.
I
Identify buggy proofs.
I
Because it is fun!
Design algorithms / programs and prove that are correct and fast
What is a proof?
Definition A mathematical proof of a proposition is a seq. of
logical deductions leading to the proposition from a base set of
premises/ axioms.
What is a proof?
Definition A mathematical proof of a proposition is a seq. of
logical deductions leading to the proposition from a base set of
premises/ axioms.
NOT a proof!
Propositions
Definition A proposition is a declarative statement that is either
true or false but not both.
Propositions
Definition A proposition is a declarative statement that is either
true or false but not both.
Examples:
1. Today is a Thursday.
2. Chennai is the capital of India.
3. All students in CS1200 are from Tamil Nadu.
4. Do you like this course?
5. Bring me a glass of water.
6. x + 3 = 10.
7. 1 + 17 = 32 − 10.
Propositions
Definition A proposition is a declarative statement that is either
true or false but not both.
Examples:
1. Today is a Thursday.
2. Chennai is the capital of India.
3. All students in CS1200 are from Tamil Nadu.
4. Do you like this course? not declarative
5. Bring me a glass of water. not declarative
6. x + 3 = 10. neither true nor false
7. 1 + 17 = 32 − 10.
Are propositions alone sufficient?
We encounter complicated statements like ...
I
Laziness is not good.
I
It is hot yet pleasant today.
I
I will have coffee or tea.
I
If I read Rosen, I will score good marks.
I
I will win the game only if I have practised earlier or my
opponent is Stanley.
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Logical connectives:
NOT : ¬p
I
(negation)
¬p : It is not hot today.
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Logical connectives:
OR : p ∨ q
I
NOT : ¬p
I
(negation)
¬p : It is not hot today.
(disjunction)
p ∨ r : It is hot today or I
will have coffee.
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Logical connectives:
OR : p ∨ q
NOT : ¬p
I
I
p ∨ r : It is hot today or I
will have coffee.
I
r ∨ s (are we willing to
drink both tea and coffee?)
(negation)
¬p : It is not hot today.
(disjunction)
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Logical connectives:
OR : p ∨ q
NOT : ¬p
I
I
p ∨ r : It is hot today or I
will have coffee.
I
r ∨ s (are we willing to
drink both tea and coffee?)
(negation)
¬p : It is not hot today.
(disjunction)
many times in English we mean
exclusive OR
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Logical connectives:
AND : p ∧ q
XOR : p ⊕ q
I
p ⊕ q : It is hot or
pleasant today
but not both.
I
(conjunction)
p ∨ r : It is hot and
pleasant today.
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Logical connectives:
AND : p ∧ q
XOR : p ⊕ q
I
p ⊕ q : It is hot or
pleasant today
but not both.
I
(conjunction)
p ∨ r : It is hot and
pleasant today.
It is hot yet pleasant today.
Compound propositions
Propositional variables:
I
p : It is hot today.
I
r : I will have coffee.
I
q : It is pleasant today.
I
s : I will have tea.
Logical connectives:
AND : p ∧ q
XOR : p ⊕ q
I
p ⊕ q : It is hot or
pleasant today
but not both.
I
(conjunction)
p ∨ r : It is hot and
pleasant today.
It is hot yet pleasant today.
many times in English we use “but /
yet” instead of “and”
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
p
T
T
F
F
Truth Table
q p→q
T
T
F
F
T
T
F
T
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I How do you express p → q in
Truth Table
terms of logical connectives?
p q p→q
T T
T
T F
F
F T
T
F F
T
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I How do you express p → q in
Truth Table
terms of logical connectives?
p q p→q
I Method-1: Look at the true
T T
T
rows and take a OR.
T F
F
F T
T
F F
T
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I How do you express p → q in
Truth Table
terms of logical connectives?
p q p→q
I Method-1: Look at the true
T T
T
rows and take a OR.
T F
F
I Method-2: Look at the false
F T
T
rows, negate and take a AND.
F F
T
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I How do you express p → q in
Truth Table
terms of logical connectives?
p q p→q
I Method-1: Look at the true
T T
T
rows and take a OR.
T F
F
I Method-2: Look at the false
F T
T
rows, negate and take a AND.
F F
T
I p → q = ¬p ∨ q .
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I
The company will replace the machine if it breaks down
within a year.
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I
The company will replace the machine if it breaks down
p → q ; p is sufficient for q to happen.
within a year.
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I
The company will replace the machine if it breaks down
p → q ; p is sufficient for q to happen.
within a year.
I
The company will replace the machine only if it breaks down
within a year.
Conditional statement
p→q
I
If the machine breaks down within a year, the company will
replace it.
p : Machine breaks down within a year.
q : The company will replace it.
I
The company will replace the machine if it breaks down
p → q ; p is sufficient for q to happen.
within a year.
I
The company will replace the machine only if it breaks down
p → q ; p is necessary for q to happen.
within a year.
Conditional statement: some more examples
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
Conditional statement: some more examples
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
1. If you score above 90 marks you get an S grade.
2. Attending all lectures is not a sufficient condition for getting
an S grade.
3. Attending all lectures is not a necessary condition for getting
an S grade.
4. If you get an S grade then you attended all lectures or you
scored above 90 marks.
5. You get an S grade only if you attend all lectures and you
score above 90 marks.
Conditional statement: some more examples
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
1. If you score above 90 marks you get an S grade. r → q
2. Attending all lectures is not a sufficient condition for getting
an S grade.
¬(p → q)
3. Attending all lectures is not a necessary condition for getting
an S grade.
¬(q → p)
4. If you get an S grade then you attended all lectures or you
scored above 90 marks. q → (p ∨ r )
5. You get an S grade only if you attend all lectures and you
score above 90 marks. q → (p ∧ r )
Conditional statement: examples revisited
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
1. Attending all lectures is not a sufficient condition for getting
an S grade. ¬(p → q)
Conditional statement: examples revisited
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
1. Attending all lectures is not a sufficient condition for getting
an S grade. ¬(p → q)
You attend all lectures yet you do not get an S grade.
Conditional statement: examples revisited
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
1. Attending all lectures is not a sufficient condition for getting
an S grade. ¬(p → q)
You attend all lectures yet you do not get an S grade.
2. Attending all lectures is not a necessary condition for getting
an S grade. ¬(q → p)
Conditional statement: examples revisited
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
1. Attending all lectures is not a sufficient condition for getting
an S grade. ¬(p → q)
You attend all lectures yet you do not get an S grade.
2. Attending all lectures is not a necessary condition for getting
an S grade. ¬(q → p)
You get an S grade but you need not have attended all
lectures.
Conditional statement: examples revisited
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
1. Attending all lectures is not a sufficient condition for getting
an S grade. ¬(p → q)
You attend all lectures yet you do not get an S grade.
2. Attending all lectures is not a necessary condition for getting
an S grade. ¬(q → p)
You get an S grade but you need not have attended all
lectures.
Caution 1: Negation of a conditional statement is NOT a “If ..
then ...” statement.
Caution 2: Necessary does NOT mean iff.
Conditional statement: mistaken with biconditional
p : You attend all lectures.
q : You get an S grade.
r : You score above 90 marks.
I
If you score above 90 marks you get an S grade. r → q
I
Incorrect implicit assumption: If you score below 90 marks
you do not get an S grade.
Conditional statement: mistaken with biconditional
p : A number is divisible by 6.
q : A number is divisible by 3.
I
p → q If a number is divisible by 6 then it is divisible by 3.
I
Clearly, does not mean than if a number is divisible by 3 then
it is divisible by 6.
Biconditional statement
p : A number is divisible by 6.
q : A number is divisible by 3.
r : A number is divisible by 2.
I
p ↔ (q ∧ r ) A number is divisible by 6 iff it is divisible by 2
and 3.
I
p → (q ∧ r ) AND (q ∧ r ) → p.
Conditional statement: inverse, converse, contrapositive
p : A number is divisible by 6.
q : A number is divisible by 3.
p→q
I
Converse: (q → p) If a number is divisible by 3 then it is
divisible by 6.
Conditional statement: inverse, converse, contrapositive
p : A number is divisible by 6.
q : A number is divisible by 3.
p→q
I
Converse: (q → p) If a number is divisible by 3 then it is
divisible by 6.
I
Inverse: (¬p → ¬q) If a number is not divisible by 6 then it
is not divisible by 3.
Conditional statement: inverse, converse, contrapositive
p : A number is divisible by 6.
q : A number is divisible by 3.
p→q
I
Converse: (q → p) If a number is divisible by 3 then it is
divisible by 6.
I
Inverse: (¬p → ¬q) If a number is not divisible by 6 then it
is not divisible by 3.
I
Contrapositive: (¬q → ¬p) If a number is not divisible by 3
then it is not divisible by 6.
Conditional statement: inverse, converse, contrapositive
p : A number is divisible by 6.
q : A number is divisible by 3.
p→q
I
Converse: (q → p) If a number is divisible by 3 then it is
divisible by 6.
I
Inverse: (¬p → ¬q) If a number is not divisible by 6 then it
is not divisible by 3.
I
Contrapositive: (¬q → ¬p) If a number is not divisible by 3
then it is not divisible by 6.
I
Conditional statement equivalent to contrapositive.
Logical equivalences
p → q ≡ ¬q → ¬p
How do you prove it?
Logical equivalences
p → q ≡ ¬q → ¬p
How do you prove it?
Truth Table
p q p→q
T T
T
T F
F
F T
T
F F
T
¬q → ¬p
T
F
T
T
Logical equivalences
p → q ≡ ¬q → ¬p
How do you prove it?
Truth Table
p q p→q
T T
T
T F
F
F T
T
F F
T
¬q → ¬p
T
F
T
T
Other methods?
I
Intuition (risky!)
I
Simplification using
logical equivalences.
Logical equivalences
Equivalence
p∧T =
p∨T =
p∨p =
p∨q =q∨p
(p ∨ q) ∨ r = p ∨ (q ∨ r )
p ∨ (q ∧ r ) = (p ∨ q) ∧ (p ∨ r )
¬(p ∨ q) = ¬p ∧ ¬q
Name
Identity
Domination
Idempotent
Commutative
Associative
Distributive
De Morgan’s Law
Lets solve ..
1. Given that the value of p → q is false, determine the value of
(p ∨ q) → q.
2. Write a compound statement that is true iff exactly two of the
three statements p, q, r are true.
3. Show without truth table:
¬(p ⊕ q) = p ↔ q.
4. An island has two kinds of inhabitants – the knaves who
always lie and the knights who always tell the truth. You
encounter two people A and B.
A says: B is a knight.
B says: The two of us are opposite types.
What are A and B?
Limitations of propositions
Recall why we defined propositions..
Using the following premises:
I
If Milind has attended CS1100, he knows fundamentals of
programming.
I
Milind has attended CS1100.
Conclusion: Milind knows fundamentals of programming.
Limitations of propositions
Recall why we defined propositions..
Using the following premises:
I
If Milind has attended CS1100, he knows fundamentals of
programming.
I
Milind has attended CS1100.
Conclusion: Milind knows fundamentals of programming.
However if we have these as our premises:
I
Everyone who attends CS1100 knows fundamentals of
programming.
I
Milind has attended CS1100.
How do we derive the conclusion?