Lecture 5

advertisement
Discrete Structures
Lecture 5
Boolean Expressions and
Propositions
1
Review of Duality
The dual PD of a boolean expression P is
constructed from P by interchanging
occurrences of
true
and false

and V

and 

and 

and

2
Metatheorem Duality
Part a:
P is valid iff ¬PD is valid.
Part b:
(P  Q) is valid iff (PD  QD) is valid.
3
Duality Review
For each expression P  Q, write the
expression PD  QD.
(a)
p  p  true
(b)
p  q  p  q  p
4
Translating English into Boolean
Expressions
A proposition is a statement that can be true or false.
Example:
It snowed today and I went skiing.
To translate into a boolean expression:
1) Locate subpropositions:
It snowed today.
I went skiing.
2) Assign these to boolean variables:
st = It snowed today
ws=I went skiing
3) Combine with obvious translation of joining words (and):
st  ws
5
Translating English to “boolean-speak”
To translate proposition p into a boolean
expression:
 Introduce boolean variables to denote
subpropositions.
 Replace these subpropositions by their
corresponding boolean variables.
 Translate the result of step 2 into a boolean
expression, using the “obvious” translations of
English words into operators.
It seems easy.......
6
Translation of English Words
and, while, but
inclusive or
exclusive or
x y
x V y
not
if x then y
¬x
x y
x y
x ¬y
7
Translation of English Words
if x then y
to x it’s necessary to y
to x it’s sufficient to y
x is sufficient for y
x is necessary for y
Note:
any x
x
x
y
x
y
y can be replaced by y
y
y
x
y
x
x
8
problem 2.5
Translate the following English statements into boolean expressions.
eh: I’ll eat my hat,
rc: it’s raining cats,
r: it’s raining,
s: I’m going swimming,
rd: it’s raining dogs
(b)
If it’s raining I’m not going swimming.
r  ¬s
(d)
It’s raining cats or dogs.
rc V rd
(f)
If it’s raining cats and dogs while I am
going swimming, I’ll eat my hat.
rc  rd  s  eh
9
The Tardy Bus Problem (2.9)
Has three assumptions and eight
conjectures. Translate the
assumptions and conjectures into
boolean expressions.
10
The Tardy Bus Conjectures
(1) If Bill takes the bus, then Bill misses his
appointment if the bus is late.
(2) Bill shouldn’t go home if Bill misses his
appointment and Bill feels downcast.
(3) If Bill doesn’t get the job, he feels downcast and
shouldn’t go home.
tb: Bill takes the bus,
ma: Bill misses his appt.,
bl: the bus is late,
gh: Bill should go home,
fd: Bill feels downcast, gj: Bill gets the job
11
tb: Bill takes the bus,
bl: the bus is late,
fd: Bill feels downcast,
ma: Bill misses his appt.,
gh: Bill should go home,
gj: Bill gets the job
(1) If Bill takes the bus, then Bill misses his
appointment if the bus is late.
tb  (bl  ma)
OR
(tb  bl)  ma
(2) Bill shouldn’t go home if Bill misses his
appointment and Bill feels down cast.
(ma  fd)  ¬gh
(parens not needed)
(3) If Bill doesn’t get the job, he feels downcast and
shouldn’t go home.
¬gj fd ¬gh
12
tb: Bill takes the bus,
bl: the bus is late,
fd: Bill feels downcast,
ma: Bill misses his appt.,
gh: Bill should go home,
gj: Bill gets the job
(4) If Bill takes the bus, then Bill does get the job if
the bus is late
(tb  bl)  gj
OR
tb  (bl  gj)
(6) If the bus is late and Bill feels downcast and he
goes home, then he shouldn’t take the bus.
(bl  fd gh)  ¬tb
(parens not needed)
(9) Bill feels downcast if the bus is late or Bill misses
his appointment.
bl V ma fd
13
Binary Counting and Truth tables
Counting in base 2 (binary):
decimal
binary
0
0
1
1
2
10
3
11
4
100
5
101
6
110
7
111
8
1000
To find all the combinations for
a truth table with n entries:
1. Write all the binary numbers
from 0 to 2n-1 using n digits.
2. Convert 0 to F and 1 to T.
14
Download