university of aberdeen computing science cs2013 mathematics for computing science adam wyner n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner PowerPoint Presentation
Download Presentation
University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner

Loading in 2 Seconds...

play fullscreen
1 / 90

University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner - PowerPoint PPT Presentation


  • 114 Views
  • Uploaded on

University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner. Slides adapted from Michael P. Frank ’ s c ourse based on the t ext Discrete Mathematics & Its Applications (5 th Edition) by Kenneth H. Rosen. Propositional Logic.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

University of Aberdeen, Computing Science CS2013 Mathematics for Computing Science Adam Wyner


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
    Presentation Transcript
    1. University of Aberdeen, Computing ScienceCS2013Mathematics for Computing ScienceAdam Wyner Slides adapted from Michael P. Frank’s course based on the textDiscrete Mathematics & Its Applications(5th Edition)by Kenneth H. Rosen

    2. Propositional Logic Rosen 5th ed., §§1.1-1.2 (but much extended) ~85 slides, ~2 lectures

    3. Foundations of Logic Mathematical Logic is a tool for working with compound statements. It includes: • A formal language for expressing them. • A methodology for reasoning about their truth or falsity. • It is the foundation for expressing formal proofs in all branches of mathematics. Frank / van Deemter / Wyner

    4. Two Logical Systems: • Propositional logic • Predicate logic (extends 1. ) Many other logical `calculi` exist, but they tend to resemble these two Frank / van Deemter / Wyner

    5. Propositional Logic (§1.1) Propositional Logic is the logic of compound statements built from simpler statements using so-called Booleanconnectives. Some applications in computer science: • Design of digital electronic circuits. • Expressing conditions in programs. • Queries to databases & search engines. George Boole(1815-1864) Chrysippus of Soli(ca. 281 B.C. – 205 B.C.) Frank / van Deemter / Wyner

    6. Propositions in natural language In propositional logic, a proposition is simply: • a statement (i.e., a declarative sentence) • with some definite meaning • having a truth value that’s either true (T) or false (F). Only values statements can have. • Never both, or somewhere “in between”. However, you might not know the truth value Frank / van Deemter / Wyner

    7. Examples of NL Propositions • “It is raining.”(In a given situation.) • “Beijing is the capital of China, and 1 + 2 = 2” But, the following are NOT propositions: • “Who’s there?”(interrogative: no truth value) • “x := x+1”(imperative: no truth value) • “1 + 2”(term: no truth value) Frank / van Deemter / Wyner

    8. Propositions in Propositional Logic • Atoms: p, q, r, …(Corresponds with simple English sentences, e.g.‘I had salad for lunch’) • Complex propositions : built up from atoms using operators: pq(Corresponds with compound English sentences, e.g., “I had salad for lunch andI had steak for dinner.”) Frank / van Deemter / Wyner

    9. Defining Propositions • Logic defines notions of atomic and complex propositions and what complex propositions “mean”. • We explain by example, giving precise definitions. Frank / van Deemter / Wyner

    10. Operators / Connectives An operator or connectivecombines with noperand expressions into a larger expression. • Unary operators take 1 operand; • Binary operators take 2 operands. • Propositional or Boolean operators operate on propositions instead of on numbers (+,-). Frank / van Deemter / Wyner

    11. Common Boolean Operators Frank / van Deemter / Wyner

    12. The Negation Operator The unary negation operator“¬” (NOT) combines with one prop, transforming the prop into its negation. E.g. If p = “I have brown hair.” then ¬p = “I do not have brown hair.” The truth table for NOT: T :≡ True; F :≡ False “:≡” means “is defined as” Operandcolumn Resultcolumn Frank / van Deemter / Wyner

    13. Truth-functionality • Truth table expresses truth/falsity of ¬pin terms of truth/falsity of p • This not possible for the operator ‘tomorrow’, or `probably’: • ‘Tomorrow p’ is true iff p is ….’?? • ‘Probably p’ is true iff p is ….’?? Frank / van Deemter / Wyner

    14. Truth-functionality • Truth table expresses truth/falsity of ¬pin terms of truth/falsity of p. • Each horizontal line of the table expresses some alternative context. • Truth-functional operator: an operator that is a function from the truth values of the component expressions to a truth value. • NOT is truth functional. Yesterday is not. • Propositional logic is only about truth-functional operators. • We can compute the values of the complex expressions. Frank / van Deemter / Wyner

    15. Comment on Truth • Not concerned with the "meaning" of a proposition other than whether it is true or false. Not about "how" we know it is true or false, but supposing it is, what else do we know. Abstraction. • The "truth" of a proposition determined "by inspection" – The book is on the table. The "real" world. • The "truth" determined by "stipulation"- suppose The book is on the table is true. Not the "real" world. • Mostly we are stipulate truth of a proposition. The truth value of P is true/false. Frank / van Deemter / Wyner

    16. The Conjunction Operator The binary conjunction operator“” (AND) combines two propositions to form their logical conjunction. E.g. If p=“I will have salad for lunch.” and q=“I will have steak for dinner.”, then pq=“I will have salad for lunch andI will have steak for dinner.” Frank / van Deemter / Wyner

    17. Conjunction Truth Table Operand columns • Note that aconjunctionp1p2  … pnof n propositionswill have 2n rowsin its truth table. • Also: ¬ and  operations together can express any Boolean truth table! more later Frank / van Deemter / Wyner

    18. The Disjunction Operator The binary disjunction operator“” (OR) combines two propositions to form their logical disjunction. p=“My car has a bad engine.” q=“My car has a bad carburator.” pq=“Either my car has a bad engine, ormy car has a bad carburetor.” Frank / van Deemter / Wyner

    19. Disjunction Truth Table • Note that pq meansthat p is true, or q istrue, or both are true! • So, this operation isalso called inclusive or,because it includes thepossibility that both p and q are true. • “¬” and “” together are also universal. Notedifferencefrom AND Frank / van Deemter / Wyner

    20. Nested Propositional Expressions • Use parentheses to group sub-expressions:“I just saw my old friend, and either he’s grown or I’veshrunk.” = f (g  s) (f g)  s would mean something different f g  s would be ambiguous • By convention, “¬” takes precedence over both “” and “”. ¬s  fmeans (¬s) f rather than ¬ (s  f) Frank / van Deemter / Wyner

    21. Logic as shorthand for NL Let p=“It rained last night”, q=“The sprinklers came on last night,”r=“The lawn was wet this morning.” ¬p = r ¬p = ¬ r  p  q = It didn't rain last night. The lawn was wet this morning, andit didn’t rain last night. Either the lawn wasn't wet this morning, or it rained last night, or the sprinklers came on last night. Frank / van Deemter / Wyner

    22. Some important ideas: • Distinguishing between different kinds of formulas • Seeing that some formulas that look different may express the same information • First: different kinds of formulas Frank / van Deemter / Wyner

    23. Tautologies A tautology is a compound proposition that is trueno matter what the truth values of its atomic propositions are! Ex.p  p[What is its truth table?] Frank / van Deemter / Wyner

    24. Tautologies • When every row of the truth table gives T. • Example: p p T T FT F T TF Frank / van Deemter / Wyner

    25. Contradictions A contradiction is a compound proposition that is false no matter what! Ex.p  p [Truth table?] Frank / van Deemter / Wyner

    26. Contradictions • When every row of the truth table gives F • Example: p p T F FT F F TF Frank / van Deemter / Wyner

    27. Contingencies All other props. are contingencies: Some rows give T, others give F Now: formulas that have the same meaning Frank / van Deemter / Wyner

    28. Propositional Equivalence Two syntactically (i.e., textually) different compound propositions may be semantically identical (i.e., have the same meaning). Here semantically identical means just that they have the same truth table for input truth values of the propositions. We call them logically equivalent. Notation: …  … Frank / van Deemter / Wyner

    29. Logical Equivalence Compound proposition p is logically equivalent to compound proposition q, written pq, IFFp and q contain the same truth values in all rows of their truth tables We will also say: they express the same truth function (= the same function from values for atoms to values for the whole formula). Frank / van Deemter / Wyner

    30. Proving Equivalencevia Truth Tables Ex. Prove that pq  (p  q). F T T T F T T F F T T F T F T T F F F T Shows that OR is equivalent to a combination of NOT and AND. Frank / van Deemter / Wyner

    31. Before introducing more connectives • … let us step back and ask a few questions about truth tables Frank / van Deemter / Wyner

    32. Questions for you to think about • What does each line of the table "mean"? • Consider a conjunction p1p2 p3How many rows are there in its truth table? • Consider a conjunctionp1p2  … pn of n propositions.How many rows are there in its truth table? • Explain why ¬ and  together are sufficient to express any Boolean truth table Frank / van Deemter / Wyner

    33. Questions for you to think about • Consider a conjunction p1p2 p3How many rows are there in its truth table? 8p1p2 p31 1 1 1 1 0 1 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 0 Two truth values (0,1) and three propositions: 23 = 8. Frank / van Deemter / Wyner

    34. Questions for you to think about 2. Consider p1p2  … pnHow many rows are there in its truth table?2*2*2*… *2 (n factors)Hence 2n (This grows exponentially!) Frank / van Deemter / Wyner

    35. Questions for you to think about 3. Explain why ¬ and  together are sufficient to express anyother complex expression in propositional logic. Frank / van Deemter / Wyner

    36. Questions for you to think about • Explain why ¬ and  together are sufficient to express any other complex expression in propositional logic. • Obviously, if we add new connectives(like ) we can write new formulas. • CLAIM: these formulas would always be equivalent with ones that only use ¬ and (This is what we need to prove). Frank / van Deemter / Wyner

    37. Relating AND and OR • Saying this in a different way: if we add new connectives, we can write new formulas, but these formulas will always only express truth functions that can already be expressed by formulas that only use ¬ and . • That is, they will be equivalent. • Example of writing a disjunction in another form (equivalence shown before): p  q  ¬(¬p  ¬q) Frank / van Deemter / Wyner

    38. Mystery Operator PQRFormula (containing P,Q,R) 1 1 1 0 1 1 0 1 1 0 1 1 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 0 Does there exist such a Formula? Suppose, given the truth values of P, Q, and R, we construct a Formula with the given resulting truth value. This is our 'mystery' operator . Can it be written equivalently with NOT and AND. Frank / van Deemter / Wyner

    39. T-values in Conjunction 3. Explain why ¬ and  together are sufficient to express any Boolean truth table • Suppose precisely two rows give T.For example, the rows where • P=T, Q=T, R=F. This is P  Q  ¬R • P=T, Q=F, R=T. This is P  ¬Q  R Frank / van Deemter / Wyner

    40. Table as a disjunction of T-rows Suppose precisely two rows give T.For example, the rows where • P=T, Q=T, R=F. This is P  Q  ¬R • P=T, Q=F, R=T. This is P  ¬Q  R • We’ve proven our claim if we can express the disjunction of these two rows: (P  Q  ¬R)  (P  ¬Q  R) Frank / van Deemter / Wyner

    41. Disjoining rows of the table • We’ve arrived if we can express their disjunction: (P  Q  ¬R)  (P  ¬Q  R) • But we’ve seen that disjunction can be expressed using  and ¬: AB  ¬(¬A  ¬B) • So: (P  Q  ¬R)  (P  ¬Q  R)  ¬(¬ (P  Q  ¬R)  (P  ¬Q  R)) • We’ve only used  and . Frank / van Deemter / Wyner

    42. Check (P  Q  ¬R) (P  ¬Q  R)  ¬(¬ (P  Q  ¬R)  (P  ¬Q  R)) 1 1 0 01 0 1 01 0 1 0 1 1 1 0 01 1 1 1 01 0 1 1 1 1 10 1 1 01 0 0 1 0 1 1 1 10 0 1 1 01 0 0 1 00 01 1 1 10 1 1 1 1 1 0 0 01 0 0 1 10 1 1 1 0 0 10 0 1 10 0 0 0 1 1 0 0 10 1 1 1 10 0 0 0 1 0 01 0 0 01 0 1 0 1 0 1 0 01 1 1 0 01 0 1 0 1 0 10 0 0 01 0 0 0 1 0 1 0 10 1 1 0 01 0 0 0 0 0 01 0 0 10 0 1 0 1 0 0 0 01 1 1 0 10 0 1 0 0 0 10 0 0 10 0 0 0 1 0 0 0 10 1 1 0 10 0 0 Notice that we only state where the new mystery connective is true as it is false elsewhere. Frank / van Deemter / Wyner

    43. About this proof … • We’ve made our task a bit easier, assuming that there were only 2 rows resulting in T • But the case with 1 or 3 or 4 or …. rows is analogous (and there are always only finitely many rows.) • So, the proof can be made precise Frank / van Deemter / Wyner

    44. Having proved this … • We can express every possible truth-functional operator in propositional logic in terms of AND and NOT • This is sometimes called functional completeness. Also universality. • Reduce other operators to other more basic operators. • Very useful in computing to reduce complexity of formulas (Normal forms) Frank / van Deemter / Wyner

    45. Let’s introduce some additional connectives • A variant of disjunction • The conditional • The biconditional Frank / van Deemter / Wyner

    46. The Exclusive Or Operator The binary exclusive-or operator“” (XOR) combines two propositions to form their logical “exclusive or”. p = “I will earn an A in this course,” q =“I will drop this course,” p q = “I will either earn an A in this course, or I will drop it (but not both!)” Frank / van Deemter / Wyner

    47. Exclusive-Or Truth Table • Note that pq meansthat p is true, or q istrue, but not both! • This operation iscalled exclusive or,because it excludes thepossibility that both p and q are true. • “¬” and “” together are not universal. Notedifferencefrom OR. Frank / van Deemter / Wyner

    48. Natural Language is Ambiguous Note that English“or” can be ambiguous regarding the “both” case! Need context to disambiguate the meaning! For this class, assume “or” means inclusive. Frank / van Deemter / Wyner

    49. Test your understanding of the two types of disjunction • Suppose p  q is true.Does it follow that pqis true? • Suppose pqis true.Does it follow that p q is true? Frank / van Deemter / Wyner

    50. Test your understanding of the two types of disjunction • Suppose p  q is true.Does it follow that pqis true?No: consider p TRUE, q TRUE • Suppose pqis true. Does it follow that p  q is true? Yes. Check each of the two assignments that make pq true:a) p TRUE, q FALSE (makes p  q true) b) p FALSE, q TRUE (makes p  q true) Frank / van Deemter / Wyner