Discrete Structures of Computer Science Propositional Logic I Gazihan Alankuş (Based on original slides by Brahim Hnich) July 26, 2012
1 Use of Logic 2 Statements 3 Logic Connectives 4 Truth Tables
Use of Logic In mathematics:
Use of Logic In mathematics: Give precise meaning to statements
Use of Logic In mathematics: Give precise meaning to statements Distinguish between valid and invalid arguments
Use of Logic In mathematics: Give precise meaning to statements Distinguish between valid and invalid arguments Provide use of correct reasoning
Use of Logic In mathematics: Give precise meaning to statements Distinguish between valid and invalid arguments Provide use of correct reasoning Natural language can be very ambiguous
Use of Logic In mathematics: Give precise meaning to statements Distinguish between valid and invalid arguments Provide use of correct reasoning Natural language can be very ambiguous He ate the cookies on the couch
Use of Logic In mathematics: Give precise meaning to statements Distinguish between valid and invalid arguments Provide use of correct reasoning Natural language can be very ambiguous He ate the cookies on the couch This is good soup
Use of Logic In mathematics: Give precise meaning to statements Distinguish between valid and invalid arguments Provide use of correct reasoning Natural language can be very ambiguous He ate the cookies on the couch This is good soup You could do with a new automobile. How about a test drive?
Use of Logic In computing:
Use of Logic In computing: Design new data/knowledge from existing facts
Use of Logic In computing: Design new data/knowledge from existing facts Design of computer circuits
Use of Logic In computing: Design new data/knowledge from existing facts Design of computer circuits Construction of computer programs
Use of Logic In computing: Design new data/knowledge from existing facts Design of computer circuits Construction of computer programs Verification of correctness of programs and circuit design
Use of Logic In computing: Design new data/knowledge from existing facts Design of computer circuits Construction of computer programs Verification of correctness of programs and circuit design Specification
Statements(propositions) Propositional logic deals with statements and their truth values
Statements(propositions) Propositional logic deals with statements and their truth values A statement is a declarative sentence that can be true or false
Statements(propositions) Propositional logic deals with statements and their truth values A statement is a declarative sentence that can be true or false Truth values are TRUE (T or 1) and FALSE (F or 0)
Example Statements 1 + 1 = 2 (statement, T)
Example Statements 1 + 1 = 2 (statement, T) The moon is made of cheese (statement, F)
Example Statements 1 + 1 = 2 (statement, T) The moon is made of cheese (statement, F) Go home! (no statement, imperative)
Example Statements 1 + 1 = 2 (statement, T) The moon is made of cheese (statement, F) Go home! (no statement, imperative) What a beautiful garden (not statement, exclamation)
Example Statements 1 + 1 = 2 (statement, T) The moon is made of cheese (statement, F) Go home! (no statement, imperative) What a beautiful garden (not statement, exclamation) Alice said: What a beautiful garden! (statement, depends on Alice)
Example Statements 1 + 1 = 2 (statement, T) The moon is made of cheese (statement, F) Go home! (no statement, imperative) What a beautiful garden (not statement, exclamation) Alice said: What a beautiful garden! (statement, depends on Alice) y + 1 = 2 (not statement, uncertain)
Compound Statements Simplest statements are called primitive statements
Compound Statements Simplest statements are called primitive statements We shall use propositional variables to denote primitive statements, p, q, r,...
Compound Statements Simplest statements are called primitive statements We shall use propositional variables to denote primitive statements, p, q, r,... We cannot decide the truth value of a primitive statement. This is not what logic does
Compound Statements Simplest statements are called primitive statements We shall use propositional variables to denote primitive statements, p, q, r,... We cannot decide the truth value of a primitive statement. This is not what logic does Instead we combine primitive statements by means of logic connectives into compound statements or formulas and look how the truth value of a compound statement depends on the truth values of the primitive statements it includes.
Compound Statements Simplest statements are called primitive statements We shall use propositional variables to denote primitive statements, p, q, r,... We cannot decide the truth value of a primitive statement. This is not what logic does Instead we combine primitive statements by means of logic connectives into compound statements or formulas and look how the truth value of a compound statement depends on the truth values of the primitive statements it includes. We will denote compound statements by Θ, Ψ,...
Logic connectives negation (not, ) It is not true that at least one politician was honest
Logic connectives negation (not, ) It is not true that at least one politician was honest conjunction (and, ) In this room there is a lady, and in the other room there is a tiger
Logic connectives negation (not, ) It is not true that at least one politician was honest conjunction (and, ) In this room there is a lady, and in the other room there is a tiger disjunction (or, ) This is a matter of death or life!
Logic Connectives implication (if... then..., ) If it rains, then we get wet
Logic Connectives implication (if... then..., ) If it rains, then we get wet exclusive or (either... or..., ) Either there is a tiger in this room, or a lady
Logic Connectives implication (if... then..., ) If it rains, then we get wet exclusive or (either... or..., ) Either there is a tiger in this room, or a lady equivalence (if and only if, ) There is a lady in this room if and only if there is a tiger in the other room!
Truth Tables Truth tables is a way to specify the exact truth value of a compound statement through the values of primitive statements involved
Truth Table of Negation Unary connective p p F (0) T (1) T (1) F (0) p: Today is Monday p: Today is not Monday
Truth Table of Conjunction Binary connective p q p q 0 0 0 0 1 0 1 0 0 1 1 1 p: Today is Monday q: It is raining p q: Today is Monday and it is raining
Truth Table of Disjunction Binary connective p q p q 0 0 0 0 1 1 1 0 1 1 1 1 p: Today is Friday q: Today is Saturday p q: Today is Friday or Saturday
Truth Table of exclusive or Binary connective p q p q 0 0 0 0 1 1 1 0 1 1 1 0 p q: You can follow the rules or be disqualified
Truth Table of implication Binary connective p q p q 0 0 1 0 1 1 1 0 0 1 1 1 p q: If black is white, then we we live in Antartica
Implication as a promise Note that logical implication does not assume any causal connection. Implication can be thought of as a promise, and it is true if the promise is kept. If I am elected, then I will lower taxes He is not elected and taxes are not lowered He is not elected and taxes are lowered He is elected and taxes are not lowered He is elected and taxes are lowered promise kept! promise kept! promise broken! promise kept!
Playing with implication Parts of implication p q p: can be viewed as a hypothesis, antecedent, premise q: can be viewed as a conclusion or consequence if p then q q follows from p a necessary condition for p is q if p, q p implies q a sufficient condition for q is p p is sufficient for q p only if q q if p q whenever p
Playing with implication Converse, contrapositive, and inverse p q: If it is raining then the home team wins Contrapositive q p If the home team does not win, then it is not raining Converse q p If the home team wins, then it is raining Inverse p q If it is not raining, then the home team does not win
Truth Table of equivalence Binary connective p q p q 0 0 1 0 1 0 1 0 0 1 1 1 p q: You pass this if and only if you work hard p q: You can take the flight if and only if you buy a ticket
Tautologies Tautology is a compound statement (formula) that is true for all combinations of truth values of its propositional variables p p p p p p 0 1 1 1 0 1
Tautologies Tautology is a compound statement (formula) that is true for all combinations of truth values of its propositional variables (p q) (q p) p q p q q p (p q) (q p) 0 0 1 1 1 0 1 1 0 1 1 0 0 1 1 1 1 1 1 1
Contradictions Contradiction is a compound statement (formula) that is false for all combinations of truth values of its propositional variables p p p p p p 0 1 0 1 0 0
Contradictions Contradiction is a compound statement (formula) that is false for all combinations of truth values of its propositional variables (p q) (p q) p q (p q) (p q) 0 0 0 0 1 0 1 0 0 1 1 0
Example Construct the truth table of the following compound statement p (p q)
Example Construct the truth table of the following compound statement p (p q) p q q p q p (p q) 0 0 1 1 1 0 1 0 0 1 1 0 1 1 1 1 1 0 1 1