You are on page 1of 26

KS091201

MATEMATIKA DISKRIT (DISCRETE MATHEMATICS

Propositional Logic

outline
Propositions Propositional variables Introduction to Logical Operators Not And Or Conditional (Implication) Bi-conditional (Bi-Implication)

Refreshment Questions
Alex, Bret, Chris, Derek, Eddie, Fred, Greg, Harold,

and John are nine students who live in a three storey building, with three rooms on each floor. A room in the West wing, one in the centre, and one in the East wing. If you look directly at the building, the left side is West and the right side is East. Each student is assigned exactly one room. Can you find where each of their rooms is: 1. Harold does not live on the bottom floor. 2. Fred lives directly above John and directly next to Bret (who lives in the West wing). 3. Eddie lives in the East wing and one floor higher than Fred. 4. Derek lives directly above Fred.

Refreshment Question
From the highest floor to lowest we have:

West Centre East ==== ====== ==== Harold Derek Eddie Bret Fred Greg Alex John Chris

Propositions
A proposition is a statement that can be either

true or false

A has an Apple laptop. B is a professor. 3 = 2 + 1 3 = 2 + 2

Not propositions:
Are you Mbah Surip? I hope that youll success in your study

Propositional variables
We use propositional variables to refer to

propositions
Usually are lower case letters starting with p (i.e. p,

q, r, s, etc.) A propositional variable can have one of two values: true (T) or false (F)
A proposition can be
A single variable: p An operation of multiple variables: p(qr)

Introduction to Logical Operators


About a dozen logical operators
Similar to algebraic operators + * - /

In the following examples,


p = Today is Friday q = Today is my birthday

Logical operators: Not


A not operation switches (negates) the truth

value
Symbol: or ~ p = Today is not Friday

p T F

p F T

Logical operators: And


An and operation is true if both operands are

true
Symbol:
Its like the A in And

p T T

q T F

pq T F

pq = Today is Friday and

today is my birthday

F
F

T
F

F
F

Logical operators: Or
An or operation is true if one of the operand is

true
Symbol: pq = Today is Friday or

pq

T
T F F

T
F T F

T
T T F

today is my birthday (or possibly both)

10

Logical operators: XOR


An xor operation is true if

either operands are true but not both Symbol:


Example:

p T T F F

q T F T F

pq F T T F

one of the two horses will win the race, but not both of them

11

Logical operators: Conditional -1


A conditional means if p then q

Symbol:
pq = If today is
p q pq

Friday, then today will be raining pq=pq

T
T F F

T
F T F

T
F T T

the Antecedent/ hypothesis/ premise


12

the Consequence/ conclusin

Logical operators: Conditional -2


Let p = I am elected and q = I will free educational fee I state: p q = If I

p
T T F

q
T F T

pq
T F T

am elected, then I will free educational fee


Consider all

possibilities
Note that if p is false, then

F F T the conditional is true regardless of whether q is true or false

13

Logical operators: Conditional -3


Let p = You get 100% on the final exam and q = You will get an A I state: p q = If you get 100% on the final, then you will get an A

p
T T F F

q
T F T F

pq
T F T T

Logical operators: Conditional 3


Alternate ways of stating a conditional:

if p, then q p implies q If p, q p only if q p is sufficient for q q is necessary for p q if p q when p A necessary condition for p is q A sufficient condition for q is p q unless p q whenever p q follows from p

15

Logical operators: Conditional 4


Conditional Inverse Converse Contrapositive

pq

pq

qp

qp

T T
T F F T F F

F
F T T

F
T F T

T
F T T

T
T F T

T
T F T

T
F T T

16

Logical operators: Bi-conditional 1


A bi-conditional means p if and only if q

Symbol:
Alternatively, it means

p T T F F

q T F T F

pq T F F T

(if p then q) and (if q then p) Note that a bi-conditional has the opposite truth values of the exclusive or

17

Logical operators: Bi-conditional 2


Let p = You take this class and q = You get a

grade p q pq Then pq means T T T You take this class if T F F and only if you get a F T F grade F F T Alternatively, it means If you take this class, then you get a grade and if you get a grade then you take (took) this class

18

Logical operators: Bi-conditional 2


Alternate ways of stating bi-conditional: p is necessary and sufficient for q If p then q , and conversely p iff q

19

Boolean operators summary


not p T T F F q T F T F p F F T T not q F T F T and pq T F F F or pq T T T F xor pq F T T F conditional pq T F T T Bi-conditional pq T F F T

Learn what they mean, dont just memorize the

table

20

Precedence of operators
Just as in algebra, operators have precedence
4+3*2 = 4+(3*2), not (4+3)*2

Precedence order (from highest to lowest):

The first three are the most important

This means that p q r s t

yields: (p (q (r)) s) (t) Not is always performed before any other operation

21

Translating English Sentences


Question 7 from Rosen, p. 17

pq It is below freezing and it is snowing pq It is below freezing but not snowing pq It is not below freezing and it is not snowing pq It is either snowing or below freezing (or both) pq If it is below freezing, it is also snowing It is either below freezing or it is snowing, (pq)(pq) but it is not snowing if it is below freezing That it is below freezing is necessary and p q sufficient for it to be snowing

p = It is below freezing q = It is snowing

22

Translation Example 2
Heard on the radio:
A study showed that there was a correlation

between the more children ate dinners with their families and lower rate of substance abuse by those children Announcer conclusions:
If children eat more meals with their family, they will have lower substance abuse 2. If they have a higher substance abuse rate, then they did not eat more meals with their family p = Children eat more meals with their family q = Children have higher substance abuse 1. p q 2. q p
1.
23

Translation Example 3
I have neither given nor received help on this

exam Let p = I have given help on this exam Let q = I have received help on this exam
pq

24

Boolean Searches
(KS091201 OR KS091323) AND Amalia AND Information System

Note that Google requires you to capitalize

Boolean operators
Google defaults to AND; many others do not

25

Bit Operations
Boolean values can be represented as 1 (true)

and 0 (false) A bit string is a series of Boolean values. Length of the string is the number of bits.
10110100 is eight Boolean values in one string

We can then do operations on these Boolean

strings
Each column is its own

Boolean operation

01011010 10110100 11101110

26

You might also like