Lesson 1: Introduction to Logic - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Lesson 1: Introduction to Logic

Description:

Determine if an implication is true given the truth value of the hypothesis ... legs of a right triangle is equal to the square of the length of the hypotenuse ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 19
Provided by: jwi6
Category:

less

Transcript and Presenter's Notes

Title: Lesson 1: Introduction to Logic


1
Lesson 1 Introduction to Logic
  • Objectives
  • Define and identify propositions
  • Combine propositions using disjunction,
    conjunction, and negation
  • Determine if an implication is true given the
    truth value of the hypothesis and conclusion
  • State the converse, inverse, and contrapositive
    of an implication
  • Give three examples of logic used in everyday
    life
  • Outline
  • Introduction
  • Syllabus
  • Logic
  • Propositions
  • Implications
  • Reading Section 1.1
  • HW
  • Section 1.1 2, 4(b,e,h), 7(e-g), 12, 16(c-g),
    29(a,b), 44
  • Section 1.2 6, 10, 13, 24, 28 (do not use truth
    tables for 24 and 28)
  • Section 1.3 1, 6, 9

2
Logic
  • The sum of the squares of the lengths of the legs
    of a right triangle is equal to the square of the
    length of the hypotenuse
  • In a given triangle, the length of the legs are 3
    and 4.

3
Proposition
  • A statement of fact that is either true or false
  • The earth is round.
  • It is sunny.
  • My feet hurt.
  • an bn cn has no solution for n gt 2.

4
Non-Propositions
  • Do you have change for a dollar?
  • Ouch!
  • Sit in the front two rows.
  • A proposition must be able to be assigned a true
    or false value.

5
Propositional Calculus
  • We can assign variables to any proposition
    (usually p, q, r, s ). Combining these with
    operators allows us to assert new propositions.
  • Negation
  • Conjunction
  • Disjunction
  • XOR
  • Truth tables can be used to assign values to
    operators or compound propositions.

6
Implications
  • An implication, noted p ? q is a proposition that
    is false when (p is true and q is false), and
    true otherwise.
  • Commonly say If p, then q
  • p implies q
  • q is necessary for p
  • q when p

7
Implications
  • If you exercise, you will lose weight
  • I will go to the movies if I get off work early.
  • If you are taller than 6, then you can dunk a
    basketball
  • Unless you have read the chapter, you will fail
    the exam

8
True Implications
  • If the moon is made of bleu cheese, then I will
    give you 100.
  • If it is sunny, then 2 2 4.
  • If it is not sunny, then 2 2 4.

9
Alternate implications
  • Converse
  • Contrapositive
  • Inverse

10
In-class exercise
  • If I have enough money, then I will go to the
    movies.
  • p
  • q
  • Contrapositive
  • Converse
  • Inverse

11
Biconditional
  • True if p and q have the same truth values, false
    otherwise.
  • p if and only if q
  • p iff q

12
Biconditional
  • You may play outside if you clean up your room.
  • p you may play outside
  • q you clean up your room

13
System Requirements
  • You may delete the file if it is not read-only
    and it is in your account, or if you are the
    system administrator.
  • p
  • q
  • r
  • s

14
Knights/Knaves
  • We are not both knights
  • p A is a knight
  • q B is a knave
  • r A and B are both knights

15
Lecture exercise
  • if (x gt 0)
  • y 6
  • z x y
  • else
  • y x
  • Derive four propositions from the above code.
  • State two implications given by this code

16
Programming
  • You wish to allow a user to write to a file in
    your account. This user must be authorized by
    entering a correct password, but cant be the
    user dtougaw. The due date is January 12 and
    the user cannot write to the file after that
    date. Before writing to the file, you must check
    that it exists and is writeable.
  • If the user cannot access the file, print out a
    related error message.

17
Programming
  • int a, b, c, d
  • a getPasswd() //returns 1 if valid Passwd is
    entered
  • b (!fopen(myfile.dat, w)) // file is
    present and open
  • c pastDueDate() // returns 1 if past the due
    date
  • d (USER dtougaw)
  • if (d !a)
  • printf(Sorry, you are unauthorized\n)
  • exit(0)
  • if (c)
  • printf(Too late\n)
  • exit(0)
  • if (!b)
  • printf(File cannot be opened\n)
  • exit(0)
  • //Run the rest of the code

18
Programming
  • if ( ( USER dtougaw ) !( getPasswd() ) )
  • printf(Sorry, you are unauthorized\n)
  • exit(0)
  • if ( pastDueDate() )
  • printf(Too late\n)
  • exit(0)
  • if ( !fopen(myfile.dat, w) )
  • printf(File cannot be opened\n)
  • exit(0)
  • //Run the rest of the code
Write a Comment
User Comments (0)
About PowerShow.com