discrete maths objective to re-introduce propositional logic 242-213, semester 2, 2014-2015 2....

40
Discrete Maths Objective to re-introduce propositional logic 242-213, Semester 2, 2014-2015 2. Propositional Logic 1

Upload: jennifer-ward

Post on 26-Dec-2015

225 views

Category:

Documents


2 download

TRANSCRIPT

  • Slide 1
  • Discrete Maths Objective to re-introduce propositional logic 242-213, Semester 2, 2014-2015 2. Propositional Logic 1
  • Slide 2
  • 1. Propositions A proposition is a sentence that is either true or false. Examples a) The Moon is made of green cheese. b) Bangkok is the capital of Thailand. c) 1 + 0 = 1 d) 0 + 0 = 2 Examples that are not propositions: a) Sit down! b) What time is it? c) x + 1 = 2 d) x + y = z 2
  • Slide 3
  • Propositional variables: p, q, r, s, A proposition that is always true = T A proposition that is always false = F Logical connectives (operators): Negation Conjunction Disjunction Implication Biconditional Compound Propositions are built from logical operators and smaller propositions: p q (p q) s 3
  • Slide 4
  • 2. Negation (not, ) The negation of p is p and has the truth table: Example: If p is The earth is round, then p is The earth is not round ppp TF FT 4
  • Slide 5
  • Venn Diagram for Draw p as a set inside the universal domain U. So p is true in the gray area: 5 U P
  • Slide 6
  • 3. Conjunction (and, ) The conjunction of p and q is p q Example: If p is I am at home and q is It is raining then p q is I am at home and it is raining pqp q TTT TFF FTF FFF 6
  • Slide 7
  • Venn Diagram for Represent p and q as sets. p q is true in the gray area: 7
  • Slide 8
  • 4. Disjunction (or, ) The disjunction of p and q is p q Example: If p is I am at home and q is It is raining then p q is I am at home or it is raining pqp q TTT TFT FTT FFF 8
  • Slide 9
  • Venn Diagram for Represent p and q as sets. p q is true in the gray area: 9 Note, that has a bigger true area than
  • Slide 10
  • 5. Implication (if-then, ) p q is an implication which can be read as if p then q Example: If p is I am at home and q is It is raining then p q is If I am at home then it is raining pqp q TTT TFF FTT FFT 10
  • Slide 11
  • Logical Jargon for p q p can be called the hypothesis (or antecedent or premise) q can be called the conclusion (or consequent) 11
  • Slide 12
  • Many Ways of Saying p q if p then q p implies q p only if q q unless p q when p q if p q whenever p p is sufficient for q q follows from p q is necessary for p 12 Very confusing, and if-then is extra confusing because it is NOT the same as a programming if-then or English if-then
  • Slide 13
  • Confusion when p = F The following implications are true (i.e p q is T) but make no sense as English If the moon is made of green cheese then I have more money than Bill Gates. If 1 + 1 = 3 then my grandmother is old 13 p = F q = F p = F q = T
  • Slide 14
  • Two Ways to Avoid Confusion Do not think of p q as if-then. Instead: 1. Translate into simpler logical connectives (usually and ). or 2. Draw a venn diagram 14
  • Slide 15
  • p q is the same as p q 15 There are many other ways of rewriting , but memorize this one.
  • Slide 16
  • Venn Diagram of p q as p q The easiest way of drawing a Venn diagram for is to use p q. It is true in the gray area: 16 1 2 3 4 is like
  • Slide 17
  • Example p = "it is raining"; q = " I have an umbrella" There are four cases to draw: 1. It is raining and I have an umbrella 2. It is raining and I do not have an umbrella 3. It is not raining and I have an umbrella 4. It not is raining and I do not have an umbrella 17 No example, so p q is false for this case Being able to draw a dot means p q is true for this case. Being able to draw a dot means p q is true for this case.
  • Slide 18
  • 6. Converse, Inverse, Contrapositive More uses of , with special names: q p is the converse of p q p q is the inverse of p q q p is the contrapositive of p q 18 useful later
  • Slide 19
  • Examples If it is sunny then I go shopping (p q) Converse: If I go shopping then it is sunny Contrapositive: If I do not go shopping, then it is not sunny Inverse: If it is not sunny, then I do not go shopping. 19
  • Slide 20
  • 7. Biconditional (iff, ) The biconditional p q is read as p if and only if q or "p iff q" True when p and q have the same value. If p is I am at home. and q is It is raining. then p q is I am at home if and only if it is raining. pqp q TTT TFF FTF FFT 20
  • Slide 21
  • Also known as Equivalence ( ) p q is true when p and q have the same value. Also called logical equality. is used when defining equivalences between propositional statements (see section 10 and later). 21
  • Slide 22
  • 8. Tautologies, Contradictions A tautology is a proposition which is always true. Example: p p A contradiction is a proposition which is always false. Example: p p pppp pp p TFTF FTTF 22
  • Slide 23
  • 9. Bigger Truth Tables A truth table for pqr rr p q p q r TTTFTF TTFTTT TFTFTF TFFTTT FTTFTF FTFTTT FFTFFT FFFTFT 23
  • Slide 24
  • Truth Tables do not Scale Up How many rows are there in a truth table with n propositional variables? 2 n (true and false cases for each variable) Truth tables cannot easily be written for more complex propositions. 24
  • Slide 25
  • 10. Proving Equivalences We can prove equivalences using truth tables. Example: is (p q) p q ? 25 yes, the same lhs rhs T T T T
  • Slide 26
  • Example: is (p q) p q ? 26 no, not the same lhs rhs T F F T
  • Slide 27
  • De Morgans Laws pqppqq ( pq) ( pq)pq TTFFTFF TFFTTFF FTTFTFF FFTTFTT This truth table shows that De Morgans Second Law holds. Augustus De Morgan 1806-1871 27 the same
  • Slide 28
  • Implication and contrapositive are equivalent. Also, converse and inverse are equivalent 28 the same
  • Slide 29
  • Equivalence is Very Useful If we have: complicated proposition simple proposition Then we can replace the complex one with the simple one. Equivalence is also useful for replacing logical operators. See the circuit examples in the next section. 29
  • Slide 30
  • Proving Equivalences with Truth Tables We can prove equivalences using truth tables but tables become very big for complex propositions. We need a different technique for proving the equivalence of larger propositions. rewrites; see section 13 30
  • Slide 31
  • 11. Logic Circuits Electronic circuits; each input/output signal can be viewed as a 0 or 1. 0 represents False 1 represents True Complicated circuits are constructed from three basic circuits called gates. The inverter (NOT gate) takes an input bit and produces the negation of that bit. The OR gate takes two input bits and produces the value equivalent to the disjunction of the two bits. The AND gate takes two input bits and produces the value equivalent to the conjunction of the two bits. 31 continued
  • Slide 32
  • More complicated digital circuits can be constructed by combining these basic circuits. For example: 32
  • Slide 33
  • Simplifying Circuits Simplify circuits (i.e. use less gates), by using equivalences. 33 p q and not p q or (p q) p q Two gates compared to three gates; different gates; less wiring
  • Slide 34
  • 34 p q and p or p (p q) p Zero gates compared to two gates; less wiring
  • Slide 35
  • 35 continued 12
  • Slide 36
  • More Logical Equivalences 36
  • Slide 37
  • To prove that, we produce a series of equivalences beginning with A and ending with B. Each line rewrites the left-hand side (lhs) to the right- hand side (rhs) by using the logic equivalences from section 12. 13. Equivalence Proofs Using Rewrites 37 A1 A2A1 A2
  • Slide 38
  • Example: Is Solution: 38 ? Yes
  • Slide 39
  • Example: Is In English, is the proposition a tautology. Solution: 39 T ? Yes
  • Slide 40
  • 14. More Information Discrete Mathematics and its Applications Kenneth H. Rosen McGraw Hill, 2007, 7th edition chapter 1, sections 1.1 1.3 40