lecture chapter 1

Upload: elle-xevierre-g

Post on 06-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Lecture Chapter 1

    1/33

    1

    CHAPTER 1

    LOGIC

  • 8/3/2019 Lecture Chapter 1

    2/33

    2

    Learning outcomes

    At theend of this topic, studentsshould beable to:

    identify a proposition.

    tell thename of the logical connectives construct truth table.

    combine the propositions by using the logicalconnectives.

    to show that a propositionis tautology /contradiction / equivalent.

    identify law of logic.

  • 8/3/2019 Lecture Chapter 1

    3/33

    3

    History

    Greek philosopher.

    Knownas the fatherof logic.

    his works contain theearliest knownformal study oflogic, which were

    incorporatedin the latenineteenthcentury into modernformal logic.

    Born on Nov. 2, 1815 inLincoln, England. Died onDec. 8, 1864 inBallintemple,

    Irelandat 49 yrs old.

    In 1854, heestablished therules of

    symbolic logic in his book TheLaws of

    Thought.George Boole

    AristotleAristotle

  • 8/3/2019 Lecture Chapter 1

    4/33

  • 8/3/2019 Lecture Chapter 1

    5/33

    5

    Logic & Computer science

    Someapplications of logic:

    - Data base theory formalize the

    definitions ofqueries.- Softwareengineering design of

    electronic computersincluding thedesign

    ofnetworks orcircuits.

    - Programming languages to provea

    program to be correct can use logic-based

    notionssuch as loop invariants.

  • 8/3/2019 Lecture Chapter 1

    6/33

  • 8/3/2019 Lecture Chapter 1

    7/33

    7

    The Statement/PropositionGame

    Earth is the only planet in the universe that

    contains life.

    Is thisastatement?Is thisastatement? yesyes

    Is thisa proposition?Is thisa proposition? yesyes

    What is the truth valueWhat is the truth valueof the proposition?of the proposition? truetrue

  • 8/3/2019 Lecture Chapter 1

    8/33

    8

    The Statement/PropositionGame

    3 + 4 = 8

    Is thisastatement?Is thisastatement? yesyes

    Is thisa proposition?Is thisa proposition? yesyes

    What is the truth valueWhat is the truth valueof the proposition?of the proposition? falsefalse

  • 8/3/2019 Lecture Chapter 1

    9/33

    9

    The Statement/PropositionGame

    y > 5

    Is thisastatement?Is thisastatement? yesyes

    Is thisa proposition?Is thisa proposition? nono

    Its truth valuedepends on thevalue of y andIts truth valuedepends on thevalue of y and

    x, but thisvalueisnot specified.x, but thisvalueisnot specified.

  • 8/3/2019 Lecture Chapter 1

    10/33

    10

    The Statement/PropositionGame

    x + y > 10

    Is thisastatement?Is thisastatement? yesyes

    Is thisa proposition?Is thisa proposition? nono

    What is the truth valueWhat is the truth valueof the proposition?of the proposition? No truth valueNo truth value

  • 8/3/2019 Lecture Chapter 1

    11/33

    11

    The Statement/PropositionGame

    Isit raining?

    Is thisastatement?Is thisastatement? nono

    Is thisa proposition?Is thisa proposition? nono

    ** It hasno truth value.** It hasno truth value.

    (Itsaquestion.)(Itsaquestion.)

  • 8/3/2019 Lecture Chapter 1

    12/33

    12

    The Statement/PropositionGame

    If the worldisround, then Columbus wasright.

    Is thisastatement?Is thisastatement? yesyes

    Is thisa proposition?Is thisa proposition? yesyes

    What is the truth valueWhat is the truth value

    of the proposition?of the proposition? probably trueprobably true

  • 8/3/2019 Lecture Chapter 1

    13/33

    13

    The Statement/PropositionGame

    x < y ifand only if y > x.

    Is thisastatement?Is thisastatement? yesyes

    Is thisa proposition?Is thisa proposition? yesyes

    What is the truth valueWhat is the truth value

    of the proposition?of the proposition?truetrue

    ( becauseits truth value doesnot depend on( becauseits truth value doesnot depend on

    specific values of x and y.)specific values of x and y.)

  • 8/3/2019 Lecture Chapter 1

    14/33

    14

    Test yourunderstanding on

    proposition. Which of the following sentences are

    proposition ?

    i. Thesunisshining.

    ii. nisa primenumber.

    iii. Takean umbrella with you.iv. Letsgo to therestaurant.

    v. Come to class!!

    vi. Thesum of two primenumbersareeven.

  • 8/3/2019 Lecture Chapter 1

    15/33

    15

    1.2 Logical Operators (Connectives) We formalize this by denoting propositions with letters

    such as p, q, r, s, andintroducingseveral logicaloperators.

    We will examine the following logical operators:

    i) Negation (NOT)

    ii) Conjunction (AND)iii) Disjunction (OR)

    iv) ExclusiveOr(XOR)

    v) Implication (if then)

    vi) Biconditional (ifand only if)

    Truth tables can be used to show how these operatorscan combine propositions to compound propositions.

  • 8/3/2019 Lecture Chapter 1

    16/33

    16

    Negation (NOT)

    Unary Operator, Symbol:

    P P

    true false

    false true

    e.g.

    P = I am a Malaysian.

    P = I am not a Malaysian

  • 8/3/2019 Lecture Chapter 1

    17/33

    17

    Conjunction (AND)

    Binary Operator, Symbol:

    P Q P Q

    true true true

    true false false

    false true false

    false false false

    e.g.P = I will have salad for lunch

    Q = I will have fried mee for dinner .

    P Q = I will have salad for lunch

    and fried mee fordinner

  • 8/3/2019 Lecture Chapter 1

    18/33

  • 8/3/2019 Lecture Chapter 1

    19/33

    19

    ExclusiveOr(XOR) Binary Operator, Symbol:

    (p or q but not both)

    P Q PQ

    true true falsetrue false true

    false true true

    false false false

    e.g.

    P = I will order Fried rice fordinner

    Q = I will order Chicken chop fordinner

    P

    Q = I will either order Friedrice or Chicken chop fordinner

  • 8/3/2019 Lecture Chapter 1

    20/33

    20

    Implication (if - then)

    Binary Operator, Symbol: p

    P Q PpQ

    true true true

    true False false

    false True true

    false False true

    e.g

    P= you study hardQ= you will get good grade

    P p Q= If you study hard thenyou will get good

    grade

  • 8/3/2019 Lecture Chapter 1

    21/33

    21

    Biconditional (ifand only if)

    Binary Operator, Symbol: m

    P Q PmQ

    true true true

    true false false

    false true false

    false false true

    e.gP = You can take the flight

    Q = You buy a ticket

    P m Q = you can take the flight ifand only if you buy a ticket

    P if Q and Q if PP if Q and Q if P

  • 8/3/2019 Lecture Chapter 1

    22/33

    22

    Which is the correct truth table

    forp q ?p q

    T T T

    T F T

    F T T

    F F F

    p q

    T T T

    T F T

    F T F

    F F T

    p q

    T T T

    T F F

    F T T

    F F T

    p q

    T T F

    T F T

    F T T

    F F T

    1. 2. 3. 4.

    Hint: Lookat thevalues of p andq that make p q false

  • 8/3/2019 Lecture Chapter 1

    23/33

    23

    1.3 Compound PropositionOne ormore propositions can be combined to form asinglecompound proposition.

    Forexample:

    Single propositions:

    m : Fatimah isa pretty girl.

    n : Fatimah isakindgirl.

    Compound proposition:

    m n : Fatimah isa pretty andkindgirl.

  • 8/3/2019 Lecture Chapter 1

    24/33

    24

    Example

    1. Show that thestatement forms (p q)and p qarenot logically equivalent.

    2. Construct the truth table for thestatement

    form (p q) (p q).

    3. Write the followingsentencessymbolically,

    letting h = It is hots = It issunny

    a) It isnot hot andit issunny.

    b) It iseitherhot orsunny.

  • 8/3/2019 Lecture Chapter 1

    25/33

    25

    Example:4. If P= It is raining and

    Q= Iam indoor

    Use thesymbols of logical connectives torepresent the followingsentences:

    i. It israiningand I am indoor.

    ii. Ifit israining then I am indoor.

    iii. It israiningif I am indoor.

    iv. It israiningifand only if I am indoor.

    v. It isnot raining.

  • 8/3/2019 Lecture Chapter 1

    26/33

    26

    1.4 Tautologies and Contradictions

    Tautology isastatement form which is true

    forall values ofstatement variables.

    Contradiction isastatement form which is false

    forall values ofstatement variables.

    Otherthan tautology & contradiction, the

    propositionsare calledcontigency.

  • 8/3/2019 Lecture Chapter 1

    27/33

    27

    1.5 TheLaws ofLogic1. Law ofDouble Negation2. De MorgansLaws

    3. CommutativeLaws

    4. AssociativeLaws

    5. Idempotent Laws

    6. Identity Laws

    7. AbsorptionLaws

    8. NegationLaws

    9. DistributiveLaws

    pp

    qpqpqpqp

    pqqppqqp

    )()()()( rqprqprqprqp

    pppppp

    cqqtpp

    ptppcp

    pqpppqpp

    )()()(

    )()()(

    rpqprqp

    rpqprqp

  • 8/3/2019 Lecture Chapter 1

    28/33

    28

    Simplify the followingstatement:

    Solution

    )()( qpqp

    lawIdentityplawNegationcp

    laweCommutativqqp

    lawveDistributiqqp

    lawnegativeDoubleqpqp

    lawssMorganDeqpqpqpqp

    )(

    )(

    )()(

    ')())(()()(

  • 8/3/2019 Lecture Chapter 1

    29/33

    29

    Rules of Inference:

    1. Modus ponens

    p p q

    If p, q.

    e.g.

    If password correct, then login permitted

    __________________

    Passwordis correct

    Loginis permitted

    2. Modus Tollen

    p p q

    If q, p.

    e.g.

    If password correct, then login permitted

    ______________

    Loginnot permitted

    Passwordincorrect.

    3. EliminitionP q

    p,

    p, qe.g.

    Either Amin is in the library or he isin the cafe .

    _____________________Amin is not in the library.So he must be in the cafe.

    4. Transitivitypp pp q

    qq pp r pp pp r e.g.r e.g.If tomorrow is not a holiday then I have to goto work.If I have to go to work then I have to takethe train.

    _____________________* If tomorrow is not a holiday then I have to

    take the train.

    If p is true thenqis true.

    // p is truethereforeqis true

    If p is true thenqis true.// qisnot truetherefore p is

    not true

    Eitherp orqis true.

    // p isnot true, thereforeqis

    true

  • 8/3/2019 Lecture Chapter 1

    30/33

    30

    Example1. Recognizing modus Ponensand Modus Tollen

    i) If Socratesisa man, then Socratesis mortal

    Socratesisa man

    .

    ii) If thesum of thedigits of371,487isdivisible by 3, then371,487isdivisible by 3.

    371,487isdivisible by 3.

    iii) .

    870,232 isnot divisible by 3.

    870,232 isnot divisible by 6.

  • 8/3/2019 Lecture Chapter 1

    31/33

    31

    2. Identify therules ofinference foreach of the following:

    i)

    If Anisahs fatheris Ahmad then Anisah could be my sister.**Anisah isnot my sister, therefore herfatherisnot Ahmad.

    ii) If you get an A forthissubject then I will buy you ice cream.

    ** You scored A forthissubject. Therefore I will buy you icecream.

    iii) x 3 = 0 or x + 2 = 0.

    ** x + 2 0

    x 3 = 0

    iv) If you invest in thestock market, then you will get rich.

    v) If you get rich, then you will be happy.

    ** If you invest in thestock market, then you will be happy.

  • 8/3/2019 Lecture Chapter 1

    32/33

    32

    Websites:

    http://www.authorstream.com/Presentation/Silvia-46066-cs201-prop-logic-Data-Structures-Discrete-Mathematics-Propositional-logi-Education-ppt-powerpoint/ (dateaccessed: 3rd June 2009)

    http://www.mathgoodies.com/lessons/toc_vol9.html (dateaccessed: 4thJune 2009)

    http://www.mathwarehouse.com/math-statements/logic-and-truth-values.php (dateaccessed: 30th July 2009)

    http://www.facstaff.bucknell.edu/mastascu/eLessonsHtml/Logic/Logic1.html

    (dateaccessed: 5th Jan 2010)

    http://www.jgsee.kmutt.ac.th/exell/Logic/Logic11.htm ( 12th Jan 2010)

    (+ exercise recommended)

  • 8/3/2019 Lecture Chapter 1

    33/33

    33

    THEEND