1 / 59

CS203 Discrete Mathematical Structures

CS203 Discrete Mathematical Structures. Logic Proposition logic. What is logic?. The branch of philosophy concerned with analysing the patterns of reasoning by which a conclusion is drawn from a set of premises, without reference to meaning or context ( Collins English Dictionary ).

boone
Download Presentation

CS203 Discrete Mathematical Structures

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. CS203Discrete Mathematical Structures Logic Proposition logic

  2. What is logic? The branch of philosophy concerned with analysing the patterns of reasoning by which a conclusion is drawn from a set of premises, without reference to meaning or context (Collins English Dictionary)

  3. Digital Logic

  4. Propositional logic • Simple types of statements, called propositions, are treated as atomic building blocks for more complex statements 1) Alexandria is a port or a holiday resort. 2) Alexandria is not a port. Therefore, Alexandria is a holiday resort

  5. Basic connectives and truth tables statements (propositions): declarative sentences that are either true or false--but not both. Eg. Ahmed Hassan wrote Gone with the Wind. 2+3=5. not statements: What a beautiful morning! Get up and do your exercises.

  6. Statement (Proposition) A Statement is a sentence that is either True or False True 2 + 2 = 4 Examples: False 3 x 3 = 8 787009911 is a prime Today is Tuesday. Non-examples: x+y>0 x2+y2=z2 They are true for some values of x and y but are false for some other values of x and y.

  7. Propositional connectives • Propositional logic has four connectives

  8. Logical Operators • About a dozen logical operators • Similar to algebraic operators + * - / • In the following examples, • p = “Today is Friday” • q = “Today is my birthday”

  9. Logical operators: Not • A “not” operation switches (negates) the truth value • Symbol:  or ~ • p = “Today is not Friday”

  10. Logical operators: And • An “and” operation is true if both operands are true • Symbol:  • It’s like the ‘A’ in And • pq = “Today is Friday and today is my birthday”

  11. Logical operators: Or • An “or” operation is true if either operands are true • Symbol:  • pq = “Today is Friday or today is my birthday (or possibly both)”

  12. Logical operators: Conditional • A conditional means “if p then q” • Symbol:  • pq = “If today is Friday, then today is my birthday” • p→q=¬pq

  13. Logical operators: Bi-conditional • A bi-conditional means “p if and only if q” • Symbol:  • Alternatively, it means “(if p then q) and (if q then p)” • Note that a bi-conditional has the opposite truth values of the exclusive or

  14. Boolean operators summary • Learn what they mean, don’t just memorize the table!

  15. Precedence of operators • Just as in algebra, operators have precedence • 4+3*2 = 4+(3*2), not (4+3)*2 • Precedence order (from highest to lowest): ¬   → ↔ • The first three are the most important • This means that p  q  ¬r→s↔tyields: (p  (q  (¬r)) →s) ↔ (t) • Not is always performed before any other operation

  16. Example s: Aya goes out for a walk. t: The moon is out. u: It is snowing. : If the moon is out and it is not snowing, then Aya goes out for a walk. If it is snowing and the moon is not out, then Aya will not go out for a walk.

  17. Translating English Sentences • p = “It is below freezing” • q = “It is snowing” • It is below freezing and it is snowing • It is below freezing but not snowing • It is not below freezing and it is not snowing • It is either snowing or below freezing (or both) • If it is below freezing, it is also snowing • It is either below freezing or it is snowing, but it is not snowing if it is below freezing • That it is below freezing is necessary and sufficient for it to be snowing pq p¬q ¬p¬q pq p→q ((pq)¬(pq))(p→¬q) p↔q

  18. Logical Equivalence p q 0 0 1 1 0 1 0 1 1 1 0 0 1 1 0 1 1 1 0 1

  19. Identity laws Like adding 0 Domination laws Like multiplying by 0 Idempotent laws Delete redundancies Double negation “I don’t like you, not” Commutativity Like “x+y = y+x” Associativity Like “(x+y)+z = y+(x+z)” Distributivity Like “(x+y)z = xz+yz” De Morgan Tables of Logical Equivalences

  20. Excluded middle Negating creates opposite Definition of implication in terms of Not and Or Tables of Logical Equivalences

  21. Fundamentals of Logic A compound statement is called a tautology(T0) if it is true for all truth value assignments for its component statements. If a compound statement is false for all such assignments, then it is called a contradiction(F0). : tautology : contradiction

  22. Propositional Logic - 2 more defn… A tautology is a proposition that’s always TRUE. A contradiction is a proposition that’s always FALSE. T T F F

  23. Tautology example Demonstrate that [¬p(p q )]q is a tautology in two ways: • Using a truth table – show that [¬p(p q )]q is always true • Using a proof (will get to this later).

  24. Tautology by truth table

  25. Tautology by truth table

  26. Tautology by truth table

  27. Tautology by truth table

  28. Tautology by truth table

  29. Tautologies, contradictions and programming Tautologies and contradictions in your code usually correspond to poor programming design. EG: • while(x <= 3 || x > 3) x++; • if(x > y) if(x == y) return “never got here”;

  30. dual Let s be a statement. If s contains no logical connectives other than and , then the dual of s, denoted sd, is the statement obtained from s by replacing each occurrence of and by and , respectively, and each occurrence of T and F by F and T, respectively. Eg. The dual of is

  31. The Principle of Duality Theorem () Let s and t be statements. If , then . First Substitution Rule (replace each p by another statement q) Ex. is a tautology. Replace each occurrence of p by is also a tautology.

  32. Converse The converse of a logical implication is the reversal of the implication. I.e. the converse of pq is qp. EG: The converse of “If Donald is a duck then Donald is a bird.” is “If Donald is a bird then Donald is a duck.” pq and qp are not logically equivalent.

  33. Converse

  34. Converse

  35. Logical Non-Equivalence of Conditional and Converse

  36. Logical Non-Equivalence of Conditional and Converse

  37. Logical Non-Equivalence of Conditional and Converse

  38. Fundamentals of Logic Compare the efficiency of two program segments. z:=4; for i:=1 to 10 do begin x:=z-1; y:=z+3*i; if ((x>0) and (y>0)) then writeln(‘The value of the sum x+y is’, x+y) end . . . if x>0 then if y>0 then … Number of comparisons? 20 vs. 10+3=13 logically equivalent

  39. Derivational Proof Techniques When compound propositions involve more and more atomic components, the size of the truth table for the compound propositions increases Q1: How many rows are required to construct the truth-table of:( (q(pr ))  ((sr)t) )  (qr ) Q2: How many rows are required to construct the truth-table of a proposition involving n atomic components?

  40. Derivational Proof Techniques A1: 32 rows, each additional variable doubles the number of rows A2: In general, 2n rows Therefore, as compound propositions grow in complexity, truth tables become more and more unwieldy. Checking for tautologies/logical equivalences of complex propositions can become a chore, especially if the problem is obvious.

  41. Derivational Proof Techniques EG: consider the compound proposition (p p )  ((sr)t) )  (qr ) Q: Why is this a tautology?

  42. Derivational Proof Techniques A: Part of it is a tautology (p p ) and the disjunction of True with any other compound proposition is still True: (p p )  ((sr)t ))  (qr ) • T  ((sr)t ))  (qr ) • T Derivational techniques formalize the intuition of this example.

  43. if NOT (blue AND NOT red) OR red then… Propositional Logic - an unfamous  (pq)  q p q (pq)  q DeMorgan’s (p q)  q Double negation p (q  q) Associativity p q Idempotent

  44. Tautology by proof [¬p(p q )]q

  45. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive

  46. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE

  47. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity

  48. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE

  49. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan

  50. Tautology by proof [¬p(p q )]q [(¬pp)(¬pq)]q Distributive [ F (¬pq)]q ULE [¬pq ]q Identity ¬[¬pq ] q ULE [¬(¬p)¬q ] q DeMorgan [p ¬q ] q Double Negation

More Related