Presentation on theme: "Grading Lecture attendance: -1% per 2 unexcused absences"— Presentation transcript:
0 ICS 253: Discrete Structures I Propositional Logic Section 1.1 Spring Semester 2014 (2013-2)Propositional Logic Section 1.1Dr. Nasir Al-DarwishComputer Science DepartmentKing Fahd University of Petroleum and Minerals
1 Grading Lecture attendance: -1% per 2 unexcused absences Assignments & Quizzes: 20%Two Major Exams: 25% per examFinal Exam: 30%
2 Expectations This is really a fun course! The course covers some of the most useful math you’ll ever learn.It teaches abstraction, describe (or model) a given problem using precise formal notationHints for successRead the textbook.Lectures really do help!Do the homework.
3 Propositional LogicTraditionally, logic distinguishes valid and invalid arguments (2-valued logic). A claim is either true or false.There are other types of logic, e.g. fuzzy logicThe building blocks of logic are propositions.A proposition (claim) is a declarative statement that is either true or false.
4 Propositions versus Not Propositions What’s a proposition?A proposition is a declarative statement that’s either TRUE or FALSE (but not both, not conditional).PropositionsNot Propositions3 + 2 = 32Bring me coffee!Math is my favorite subject.3 + 2Every cow has 4 legs.Do you like Cake?There is other life in the universe.I will go fishing tomorrow.X – 2 = 10 (depends on X)
5 Atomic versus Compound Propositions A proposition is either atomic (simple) or compoundA compound proposition is formed by combining simple propositions using logical operators (operations)Logical OperationSymbolNegation (NOT)Conjunction (AND)Disjunction (OR)Exclusive ORImplication (imply)Biconditional (2-way imply)
6 Logical OperationsLet p & q be propositions, then the following are compound propositions:Negation: p = not pConjunction: p q = p AND qDisjunction: p q = p OR qExclusive OR: p q = p XOR qImplication: p q = if p then qBiconditional: p q = p if and only if q
7 Precedence of Logical Operators In a parenthesized expression, the inner most parenthesized part is computed firstBinary operators with same precedence are applied left-to-right; unary are applied right-to-leftThe following is the order of operators by precedence , , v , , This means for example (assuming parenthesis are not present)(((p(q)) v p v q) q) ((p(q)) v p)
8 Truth TablesA truth table shows the truth values of a compound proposition in relation to the truth values of its constituent propositionsNormally, the truth table will have as many rows as the different possible truth value of its constituent propositions. For example, a compound proposition involving two simple propositions P, Q will have 4 rows (4 different T/F combinations for P and Q).
9 Propositional Logic - negation Suppose p is a proposition.The negation of p is written p and has meaning:“It is not the case that p.”Ex. P = Pizza is my favorite food. P = It is not the case that pizza is my favorite food. More simply, pizza is NOT my favorite food.ppFTNote that p is a proposition!Truth table for negation
10 Propositional Logic - conjunction Conjunction corresponds to English “and”p q is true exactly when p is true and q is true (or both are true).Ex. Amy is curious AND clever.pqp qFTTruth table for conjunction
11 Propositional Logic - disjunction Disjunction corresponds to English “or”p q is true when p is true or q is true (or both are true).Ex. Michael is brave OR nuts.pqp qFTTruth table for disjunction
12 The implicationThe implication p q corresponds to English: “if p then q” or “p implies q”P Q can be considered as a contract that relates a condition P to a conclusion QP = build me a house, Q = pay you $1 millionIf you build me a house then I will pay you $1 millionThe contract is violated if the house is built but the payment is not madep q is false only in the case where p is true and q is falseIf p then 2+2=4. (This is true. Why?)pqp qFTTruth table for implication
13 Propositional Logic - logical equivalence How many different logical binary operations could we define?16How many different logical operations do we need???To answer, we need the notion of “logical equivalence.”p is logically equivalent to q if their truth tables are the same. Logical equivalence is denoted by p q (or p q).
14 Propositional Logic - logical equivalence Challenge: Try to find a proposition that is equivalent to p q, but that uses only the connectives , , and .pqp qFTpq p p qFT
15 Propositional Logic – a proof of one famous This is a “proof” of “law of distributivity.”Distributivity: p (q r) (p q) (p r)All truth assignments for p, q, and r.pqrq rp (q r)p qp r(p q) (p r)FT
16 Expressing Implications The implication p q essentially says that we cannot have p true yet q is false, (p q).Thus, p q (p q) (1) . (The equivalence can be shown by truth table)Simplifying the RHS (use DeMorgan’s law) , gives p q p q (2)It is important to observe that p q also means (because we cannot have p and not q): not q not pIt is easy to show that p q q p (3)This last equivalence is known as the ContraPositive (negative of positive) .I liken it to “the cub is half full the cub is half empty”
17 Expressing Implications – cont. Definition: p is sufficient for q if whenever p is true, q is true.Thus, p q means that p is sufficient for q.Definition: p is necessary for q if whenever p is false, q is false.Thus, p q means that q is necessary for q. (recall from previous slide that p q q p)
18 Expressing Implications – cont. The following are some of the ways of expressing p qp implies qif p then qif p, qq if p (stating the conclusion first)p only if q* (see next two slides for justification)p is sufficient for qq is necessary for pq whenever (when) pq follows from pq unless ¬p*** These seem confusing
19 Expressing Implications – cont. p q can be expressed as:p only if q:p cannot be true if q is not trueThis corresponds to the contrapositive of p qq unless pIf p is false, then q must be trueExample:If You fail the final exam then you will get FYou will get F unless you do not fail the final exam
20 Propositional Logic - biconditional The biconditional proposition p ↔ q (read as, p if and only if q) states that p and q are always equal (either they are both true or both false)The biconditional proposition p ↔ q is equivalent to “(p q) and (q p)”Because in the expression “p if and only if q” , “p if q” is q p,it follows that p q is “p only if q”Question: Is p ↔ q (p q) (p q)?pqp ↔ qFTTruth table for biconditional
21 Propositional Logic - some definitions Note: p q q pContrapositives: p q and q pEx. “If it is noon, then I am hungry.”“If I am not hungry, then it is not noon.”Converses: p q and q p“If I am hungry, then it is noon.”Inverses: p q and p q“If it is not noon, then I am not hungry.”
22 Propositional Logic - more definitions… A tautology is a proposition that’s always TRUE.A contradiction is a proposition that’s always FALSE.ppp pp pTF
23 Translating English Sentences English (and every other human language) is often ambiguous. Translating sentences into compound propositions removes the ambiguity.Example: How can this English sentence be translated into a logical expression?“You can access the Internet from campus only if you are a computer science major or you are not a freshman.”Solution: Let a, c, and f represent “You can access the Internet from campus”, “You are a computer science major”, and “You are a freshman” The sentence can be translated into:a → (c ν ¬f).
24 Translating English Sentences Example: How can this English sentence be translated into a logical expression?“You cannot enter into the pool if you are under 4 feettall unless you are older than 16 years old.”Solution: Let p, r, and s represent “You can enter into the pool” ,“You are under 4 feet tall”, and “You are older than 16 years old” The sentence can be translated into:(r Λ ¬ s) → ¬p.
25 Propositional Logic – why?… We’re primarily using propositional logic as a foundation for formal proofs. Later we will study different proof methods and these are needed for developing (or ensuring correctness) of algorithms.Propositional logic is a key to writing correct program code…you can’t do any kind of conditional (if) statement without understanding the condition you’re testing.The logical operations we’ve discussed are also found in hardware and are called “logic gates.”