02 - Propositional logic(miles

2
Propositional logic
CSE 20: Discrete Mathematics
for Computer Science
What is (and isn’t) a proposition?
Propositional variables
Propositional variables and formulas
1.
2.
3.
!
Prof. Miles Jones
not, and, or
Implication
4.
!
3
implies (if/then), if and only if (iff)
4
WHY isn’t “What is a lunar
eclipse?” a proposition?
1. What is (and isn’t) a
proposition?
A.
B.
C.
D.
Because only “yes/no” questions can be
propositions (ex: “Do you like CSE 20?”
would be a proposition).
Because questions can never be
propositions.
Because the answer changes over time
(CSE 20 is in different rooms each quarter).
None/more/other.
5
Who saw the lunar eclipse last
night?
A.
B.
C.
I did
I did not
I wanted to see it but I missed it
6
Proposition Examples
!I
am from California
! 4+1=-8
! 1+2+3=6
! If
I wake up at 7:45 then I can make it to
class on time.
8
7
Example of things that are
not propositions
! Where
is the Price center?
Propositions
!
!
! x+4=8
! this
Sentences that are either true or false
!
statement is false
!
!
3+5=7
1+1=7
My name is Scooby Doo
NO:
!
Questions
!
Imperatives (commands)
!
For this class, we’ll not worry about differences of
opinion
!
!
!
Is 3 + 5 equal to 7?
Go to school.
iPhones are better than Android phones.
9
10
Back to the algebra analogy
!
!
3. Propositional variables
!
!
11
2x + 6 ?= 2 (x + 3)
In Algebra, we study the forms of equations
that are equal to each other (irrespective of
what x is).
In logic, we study the forms of sentences that
are equivalent to each other (irrespective of
the particular facts/propositions in question).
In both Algebra and logic, we abstract these
out by just assigning them a variable name.
12
Propositional variables
!p
= “You study.”
! q = “You already knew all the material.”
! r = “You will get an A in the class.”
Propositional formulas
! Use the variables to construct more complex
relationships:
!
!
!
s = if (p or q) then r.
This newly constructed thing is also a sentence
that is either true or false—also a proposition!
Is s (A) True or (B) False?
4. Propositional formulas
13
Logical connectives
! and
! or
14
Practice: Make an English sentence
into a propositional formula
s = “If you want to learn logic, then you should
take CSE 20.”
A. p = “learn logic”, q = “CSE 20”, s = p IMPLIES q
B. p = “If you want to learn logic”, q = “then you
should take CSE 20”, s = p AND q
C. p = “If you want to learn logic”, q = “then you
should take CSE 20”, s = p IMPLIES q
D. p = “you want to learn logic”, q = “you should
take CSE 20,” s = p IMPLIES q
E. p = “you want to learn logic”, q = “take CSE 20,”
s = p AND q
!
! not
! if/then,
implies
and only if, iff
! All these take two* propositions and
connect them into a new proposition
! if
15
“All these take two* propositions and connect them into a new
proposition.”
Question: How do we know whether
the new proposition is true?
!
!
!
If the answer is, “well, we have to read the
proposition and decide if it seems true on a caseby-case basis,” then logic FAIL.
Our whole purpose in studying logic is to have a
known way of determining this based on the form
of the proposition’s composition and the truth of
each input variable.
We summarize these “known ways of
determining” in truth tables.
16
Truth tables: not
p
¬p
F
T
T
F
! If
“I am Iron Man.” is true,
then what do we know
about the negation: “I am
not Iron Man.”?
! We know it must be false.
! It doesn’t matter what the
sentence is, taking the
negation of a sentence will
give you a sentence with
the opposite truth value.
17
18
Truth tables: AND
p
F
F
T
T
q
F
T
F
T
p AND q
A.
B.
C.
D.
E.
I’m interested in
seeing if this
makes intuitive
sense to you—
can you explain
why each output
makes sense,
using example
sentences?
Truth tables: OR
p
F
F
T
T
T, F, F, T
F, T, T, T
F, F, F, T
F, T, T, F
None/more/other
19
Practice: IMPLIES
p = “I had breakfast this morning.” (assume True)
!
q = “I got all A’s in high school.” (assume True)
!
r = “My mom thinks I’m cool.” (assume True)
Which of the following are true?
A. p IMPLIES q
B.
r IMPLIES q
C. q IMPLIES r
D. None/More/Other
q
F
T
F
T
p OR q
A.
B.
C.
D.
E.
I’m interested in
seeing if this
makes intuitive
sense to you—
can you explain
why each output
makes sense,
using example
sentences?
T, F, F, T
F, T, T, T
F, F, F, T
F, T, T, F
None/more/other
20
Note about implication and causality
!
!
!
!
!
In logic, we are looking at the form of the
arguments
s = p IMPLIES q
To know if the proposition s is true, it is not
necessary for p to cause q
To determine if s is true, we only care what the
truth values of p and q are.
21
22
Truth tables: IMPLIES
p
F
F
T
T
q
F
T
F
T
p IMPLIES q
A.
B.
C.
D.
E.
Making our own connective:
AtLeastOneOfTheseThree
ALOOTT(p,q,r)
T, T, F, T
F, T, T, T
F, F, F, T
F, T, T, F
None/more/
other
! Let’s
p
q
p OR q
F
F
F
F
T
T
T
F
T
T
T
T
make a truth table for ALOOTT. How
many rows and columns should be in our
truth table (ignoring header row)?
A. 5 rows, 4 columns
B. 6 rows, 4 columns
C. 7 rows, 4 columns
D. 8 rows, 4 columns
E. 9 rows, 4 columns