1 / 26

ICS 253: Discrete Structures I

ICS 253: Discrete Structures I. Spring Semester 2014 (2013-2). Propositional Logic Section 1.1. Dr. Nasir Al-Darwish Computer Science Department King Fahd University of Petroleum and Minerals darwish@kfupm.edu.sa. Grading. Lecture attendance: -1% per 2 unexcused absences

sumana
Download Presentation

ICS 253: Discrete Structures I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ICS 253: Discrete Structures I Spring Semester 2014 (2013-2) Propositional LogicSection 1.1 Dr. Nasir Al-Darwish Computer Science Department King Fahd University of Petroleum and Minerals darwish@kfupm.edu.sa

  2. Grading • Lecture attendance: -1% per 2 unexcused absences • Assignments & Quizzes: 20% • Two Major Exams: 25% per exam • Final Exam: 30%

  3. 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 notation Hints for success • Read the textbook. • Lectures really do help! • Do the homework.

  4. Propositional Logic • Traditionally, logic distinguishes between valid and invalid statements (2-valued logic). That is, a proposition (claim) is either true or false. • There are other types of logic, e.g. fuzzy logic • The building blocks of logic are propositions. • A proposition (claim) is a declarative statement that is either true or false.

  5. 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).

  6. Atomic versus Compound Propositions • A proposition is either atomic (simple) or compound • A compound proposition is formed by combining atomic propositions using logical operations (operators)

  7. Logical Operations • Let p & q be propositions, then the following are compound propositions: • Negation: p = not p • Conjunction: pq = p AND q • Disjunction: pq = p OR q • Exclusive OR: pq = p XOR q • Implication: pq = if p then q • Biconditional: pq = p if and only if q

  8. Precedence of Logical Operators • In a parenthesized expression, the inner most parenthesized part is computed first • Binary operators with same precedence are applied left-to-right; unary are applied right-to-left • The 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)

  9. Truth Tables • A truth table shows the truth values of a compound proposition in relation to the truth values of its constituent propositions • Normally, 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).

  10. Note that p is a proposition! 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.” • Example: 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. Truth table for negation

  11. 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). • Example: Amy is curious AND clever. Truth table for conjunction

  12. Propositional Logic: Disjunction Disjunction corresponds to English “or” p  q is true when p is true or q is true (or both are true). • Example: Michael is brave OR nuts. Truth table for disjunction

  13. Propositional Logic: Implication The implicationpqcorresponds 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 Q • P = build me a house, Q = pay you $1 million • If you build me a house then I will pay you $1 million • The contract is violated if the house is built but the payment is not made • pq is false only in the case where p is true and q is false • If p then 2+2=4. (This is true. Why?) Truth table for implication

  14. ?? 16 Logical Equivalence How many different logical binary operations could we define? How many different logical operations do we need? To answer, we need the notion of “logical equivalence.” p is logically equivalentto q if their truth tables are the same. Logical equivalence is denoted by pq (or pq).

  15. Logical Equivalence, cont. Challenge: Try to find a proposition that is equivalent to pq, but that uses only the connectives , , and .

  16. Propositional Logic, a proof of one famous  Distributivity: p (qr) (p q)  (pr) The above truth table is a “proof” of “law of distributivity for over .” Note: In logic,  distributes over . Also,  distributes over .

  17. 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 p It 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”

  18. Expressing Implications, cont. Definition: p is sufficient for q if whenever p is true, qis true. Thus, pq means that p is sufficient for q. Definition: p is necessary for q if whenever p is false, qis false. Thus, pq means that q is necessary for p. (Recall from previous slide that pq  q  p)

  19. Expressing Implications, cont. The following are some of the ways of expressing pq • p implies q • if p then q • if p, q • q if p (stating the conclusion first) • p only if q* (see next two slides for justification) • p is sufficient for q • q is necessary for p • q whenever (when) p • q follows from p • q unless ¬p* • ** These seem confusing

  20. Expressing Implications, cont. pq can be expressed as: • p only if q: • p cannot be true if q is not true • This corresponds to the contrapositive of pq • q unless  p • If  p is false, then q must be true • Example: • If You fail the final exam then you will get F • You will get F unless you do not fail the final exam

  21. Propositional Logic: Biconditional The biconditional proposition p↔q (read as, pif 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)? Truth table for biconditional

  22. Propositional Logic, Some Definitions Contrapositive: The Contrapositive of pq is q  p • Example: "If it is noon, then I am hungry." Contrapositive: “If I am not hungry, then it is not noon.” • Note: This is a must-remember because an implication is logically equivalent to its contrapositive. Converse: The Converseof pq is q  p • Example: "If it is noon, then I am hungry." Converse: "If I am hungry, then it is noon." Inverse: The Inverseof pq is p  q • Example: "If it is noon, then I am hungry. " Inverse: "If it is not noon, then I am not hungry."

  23. Propositional Logic, More Definitions A tautology is a proposition that’s always TRUE. A contradiction is a proposition that’s always FALSE.

  24. Translating English Sentences • English (and every other human language) is often ambiguous. Translating sentences into compound propositions removes the ambiguity. • Question: 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, respectively, denote "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).

  25. 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 feet tall unless you are older than 16 years old." Solution: Let p, r, and s, respectively, denote "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.

  26. Why Study Propositional Logic? • We will be using propositional logic as a foundation for formal proofs. Later we will study different proof methods; 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. We gives examples of this in next lecture. • The logical operations we’ve discussed are also found in hardware and are called "logic gates" .

More Related