0% found this document useful (0 votes)
50 views53 pages

Discrete Structures: Topic 1 - Logic: Propositional Logic

The document discusses propositional logic and propositional connectives. It begins by explaining why logic is useful, particularly in computer science applications. It then defines propositions as statements that are either true or false. Compound propositions are built from atomic propositions using Boolean connectives. The six main connectives discussed are negation, conjunction, disjunction, exclusive or, implication, and biconditional. Truth tables are provided to explain the meaning and evaluation of statements using each connective. Examples are given to illustrate how connectives combine propositions and their interpretation in English.

Uploaded by

nehme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views53 pages

Discrete Structures: Topic 1 - Logic: Propositional Logic

The document discusses propositional logic and propositional connectives. It begins by explaining why logic is useful, particularly in computer science applications. It then defines propositions as statements that are either true or false. Compound propositions are built from atomic propositions using Boolean connectives. The six main connectives discussed are negation, conjunction, disjunction, exclusive or, implication, and biconditional. Truth tables are provided to explain the meaning and evaluation of statements using each connective. Examples are given to illustrate how connectives combine propositions and their interpretation in English.

Uploaded by

nehme
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Discrete Structures

Topic 1 – Logic: Propositional Logic


(Ch 1.1)*

CMPS 211 – Fall 2017 – American University of Beirut

* Extracted from Discrete Mathematics and It’s Applications book slides

1
Why logic?
}  Logic is a set of principles that can be used to reason
about (mathematical) statements
}  For instance, let’s say we want to formally express and
reason about the following statement:
}  “For every positive integer n, the sum of the positive
integers not exceeding n is n(n+1)/2”
}  We can formally express the above statement using
logic
}  We can also prove the above statement or argue
whether it is true or false using logic

2
Why logic? (cont.)
}  Logic has numerous applications to Computer Science
}  Used in the design of computer circuits
}  Used in the construction of computer programs
}  Used to verify the correctness of programs
}  Used to ensure the security of a system
}  Used heavily in artiJicial intelligence

3
Propositional Logic

4
Propositions
}  A proposition is a declarative statement that is either true or
false

}  Examples of propositions:
a)  The Moon is made of white cheese
b)  Toronto is the capital of Canada
c)  A week has more days than a month
d)  1 + 0 = 1
e)  0 + 0 = 2

}  Examples that are not proposition


a)  Sit down! - command
b)  What time is it? - question
c)  1 + 2 - expressions with a non-true/false value
d)  This statement is false – a paradox

5
Atomic propositions
}  We use letters (p, q, r, s, …) to denote atomic
propositions
}  Also called propositional variables
}  Similar to x, y, z, … for numerical variables
}  For example, let p be the proposition that the earth is round
and q be the proposition that the moon is Jlat
}  These represent a single statement that cannot be
“decomposed”

6
Compound propositions
}  Compound propositions are built up from atomic
propositions by the use of Boolean connectives. Also
called propositional formulae.
}  Propositional Logic is the logic of propositional
formulae and their meaning
}  First developed by the Greek philosopher Aristotle more
than 2300 years ago
}  George Boole introduced Boolean Algebra in 1854

7
Propositional Connectives

8
Propositional Operators/Connectives
}  An operator or connective combines one or more operand expressions
into a larger expression (e.g., “+” in numeric expressions)
}  Unary operators take 1 operand (e.g., −3)
}  binary operators take 2 operands (e.g., 3 × 4)

}  Propositional or Boolean operators operate on propositions (or their


truth values) instead of numbers

}  There are six main operators
}  Negation ¬
}  Conjunction ∧
}  Disjunction ∨
}  The Exclusive Or ⊕
}  Implication →
}  Biconditional ↔

9
Connectives: Negation
}  The negation of a proposition p is denoted by ¬p
}  In an English statement, we express ¬p as follows:
“It’s not the case that p”
}  ¬p is true if p is false and is false if p is true
}  Example:
}  If p denotes “I am at home”,
}  then ¬p denotes “It is not the case that I am at home” or
more simply “I am not at home”
}  The negation of a proposition p has this truth table
p ¬p
T F
F T
10
Connectives: Conjunction
}  The conjunction of propositions p and q is denoted by
p∧q
}  It is the proposition “p and q”
}  p ∧ q is true when both p and q are true and is false
otherwise

}  Example:
}  If p denotes “I am at home”, and
}  q denotes “It is raining”
}  then p ∧q denotes “I am at home and it is raining”

11
Conjunction (cont.)
}  The conjunction of propositions p and q has this truth
table

p q p∧q
T T T
T F F

F T F
F F F

12
Connectives: Disjunction
}  The disjunction of propositions p and q is denoted by
p ∨q
}  It is the proposition “p or q”
}  p ∨q is false when both p and q are false and is true
otherwise

}  Example:
}  If p denotes “I am at home”, and
}  q denotes “It is raining”
}  then p ∨q denotes “I am at home or it is raining”

13
Disjunction (cont.)
}  The disjunction of propositions p and q has this truth
table

p q p ∨q
T T T

T F T
F T T
F F F

14
Connectives: The Exclusive Or
}  The exclusive or of p and q is denoted by p ⊕ q
}  We say p XOR q
}  p ⊕ q is true when exactly either p or q is true and is
false otherwise

}  Example:
}  If p denotes “I am at home”, and
}  q denotes “It is raining”
}  then p ⊕ q denotes :“either I am at home or it is raining”
but not both

15
The Exclusive Or (cont.)
}  Note that English “or” can be ambiguous regarding the
“both” case!
}  “Pat is a singer or
Pat is a writer” ∨

}  “Pat is a man or
Pat is a woman” ⊕

}  Need context to understand the meaning!

}  For this class, assume “or” means inclusive

16
The Exclusive Or (cont.)
}  The exclusive or of propositions p and q has this truth
table

p q p ⊕q
T T F
T F T
F T T
F F F

17
Connectives: Implication
}  The conditional statement or implication p →q is the
proposition “if p, then q ”
}  p →q is false when p is true and q is false, and is true
otherwise
}  p is called the hypothesis (or antecedent or
premise) and q is called the conclusion (or
consequence)
}  Example:
}  If p denotes “I am at home”, and
}  q denotes “It is raining”
}  then p →q denotes “If I am at home then it is raining”

18
Implication (cont.)
}  The implication or conditional statement p →q has
this truth table

p q p →q
T T T
T F F
F T T
F F T

19
Understanding Implication
}  In p →q there does not need to be any connection
between the hypothesis and the conclusion

}  These implications are perfectly Jine, but would not be


used in ordinary English
}  “If the moon is made of green cheese, then I have more
money than Bill Gates ”
}  “If 1 + 1 = 3, then pink elephants can Jly”

20
Examples
}  “If you get 100% on the Jinal, then you will get an
A’’
}  Interpretation:
}  If you manage to get a 100% on the Jinal, then you
would expect to receive an A
}  If you do not get a 100%, you may or may not receive
an A, depending on other factors (such as…)
}  However, if you do get 100%, but the professor does
not give you an A, you will feel cheated

21
More Examples
}  “When I got elected, I will lower the taxes’’
}  Interpretation:
}  If the politician is elected, voters would expect the taxes
to get lower
}  If the politician is not elected, then the voters have no
expectations regarding the taxes, it might get lower,
higher, or stay the same.
}  It is only when the politician is elected and the taxes are
not lower, the voters would say that the politician has
broken his campaign pledge

22
Different Ways of Expressing p →q
}  if p, then q }  q if p
}  if p, q }  q whenever p
}  p implies q }  q when p
}  p only if q }  q follows from p
}  a necessary condition }  q unless ¬p
for p is q }  q is necessary for p
}  p is sufJicient for q }  a sufJicient condition for
q is p

23
Sufficient
}  “if p then q’’ expresses the same thing as “p
is sufJicient for q”
}  This is basically saying that p holding is
p q p →q
sufJicient for concluding that q will also hold
F F T
}  Example: F T T
}  “if p then q’’: If Maria learns discrete mathematics, T F F
then she will Jind a good job T T T
}  “p is sufJicient for q’’: Learning discrete
mathematics is sufQicient for Maria to Jind a good
job
}  If Maria doesn’t learn discrete mathematics, she might
Jind a good job or not, however if she does learn
discrete mathematics, she will Jind a good job for sure

24
Necessary
}  “if p then q’’ expresses the same thing as “q
is necessary for p’’
}  This is basically saying that q holding is a p q p →q
necessary conclusion for a holding premise p F F T
F T T
}  Example: T F F
}  “if p then q’’: If you can access the Internet, then T T T
you have paid a subscription fee
}  “q is necessary for p’’: Paying a subscription fee
is necessary for being able to access the Internet
}  If you can access the Internet, then you must have paid a
subscription fee, however if you cannot access the
Internet, you may have paid a subscription fee or not

25
Only If
}  “if p then q’’ expresses the same thing as “p
only if q’’
}  This is basically saying that p cannot be true p q p →q
when q is not true F F T
F T T
}  Example: T F F
T T T
}  “if p then q’’: If you can access the Internet,
then you have paid a subscription fee”
}  “p only if q’’: You can access the Internet
only if you pay a subscription fee
}  If you haven’t paid a subscription fee, you cannot access
the Internet, however if you did pay a subscription fee,
you might be able to access the Internet or not
26
Unless
}  “if p then q’’ expresses the same thing as “q
unless ¬p’’
}  This is basically saying that q will be true
p q p →q
except if p is false F F T
}  Example: F T T
T F F
}  “if p then q’’: If Maria learns discrete T T T
Mathematics, then she will Qind a good job
}  “q unless ¬p’’: Maria will Qind a good job unless
she does not learn discrete mathematics
}  We surely know Maria will get a good job, unless she
doesn’t learn discrete Mathematics – in that case, we
don’t know whether she’ll Jind a good job or not

27
Converse, Contrapositive, and Inverse
}  From p →q, we can form new conditional statements
}  q →p is the converse of p →q
}  ¬q → ¬ p is the contrapositive of p →q
}  ¬ p → ¬ q is the inverse of p →q
}  Out of these three conditional statements formed from
p → q, only the contrapositive always has the same
truth value as p → q
}  The other two might seem to have a similar meaning,
but actually translate to different premises and
conclusions

28
Example
Let p denote “I am elected president”, and
q denote “I will make healthcare free”

}  Original p →q : “If I am elected president, I will make
healthcare free”
}  Converse q →p : “If the healthcare was made free, then I am
elected president”
}  Contrapositive ¬q → ¬p: “If healthcare wasn’t made free,
then I haven’t been elected president”
}  Inverse ¬p→ ¬q : “If I wasn’t elected president, then the
health care won’t be made free”


29
Example Explained
}  The contrapositive clearly means the same thing as the
original statement
}  I made a pledge that healthcare will be made free when I get
elected to presidency
}  Consequently, if the healthcare wasn’t made free, then surely I
haven’t been elected for presidency
}  The converse, on the other hand, means something else
}  It says that observing healthcare made for free will lead to
concluding that I have been elected for presidency, which isn’t
what the original statement says
}  The original statement keeps space for the case when I don't get
elected for presidency, yet someone else makes healthcare for
free
}  The same logic applies for the inverse

30
Exercise
}  Find the converse, inverse, and contrapositive of “It
raining is a sufJicient condition for me not going to
town”

}  Solution:
}  Original : If it is raining, then I won’t go to town
}  Converse: If I do not go to town, then it is raining
}  Inverse: If it is not raining, then I will go to town
}  Contrapositive: If I go to town, then it is not raining

31
Another Exercise
}  Find the converse, inverse, and contrapositive of
“The home team wins whenever it is raining”

}  Solution:
}  Original: if it is raining , then the home team wins
}  Converse: if the home team wins, then it is raining
}  Inverse: if it is not raining, the home team won’t win
}  Contrapositive: If the home team doesn’t win, then it is not
raining

32
Connectives: Biconditional
}  The biconditional proposition p ↔q is the proposition “p if
and only if q ”
}  The biconditional p ↔q is true when p and q have the same truth
values and is false otherwise
}  Also called bi-implications

}  Example:
}  If p denotes “buying a ticket”,
}  and q denotes “can take a Jlight”
}  then p ↔ q denotes “I can take a Jlight if and only if I buy a ticket”
}  This statement is true when you buy a ticket and can take a Qlight,
Or when you don’t buy a ticket and can’t take a Qlight
}  It is false when you buy a ticket and can’t take a Qlight (like when the
airlines bumps you)
}  Or when you don’t buy a ticket and can take a Qlight (like when you
win a ticket)

33
Biconditional
}  The biconditional proposition p ↔q has this truth table

p q p ↔q
T T T
T F F
F T F
F F T

34
Expressing the Biconditional
}  Some alternative ways “p if and only if q” is expressed
in English
}  p iff q
}  if p then q , and conversely
}  p is necessary and sufJicient for q
}  Example:
}  You will be always informed if and only if you read a
newspaper everyday
}  If you read a newspaper everyday, then you will be
informed, and conversely
}  To be always informed, it is necessary and sufJicient to read
a newspaper everyday
35
Implicit Use Of Biconditionals
}  Human natural language is not explicit on
biconditionals most of the times
}  People use “if, then” and “only if ” constructs and mean
“if and only if ” implicitly
}  For example, consider the statement in English:
“If you Jinish your meal, then you can have dessert”
}  What is really meant is “You can have dessert if and
only if you Jinish your meal”
}  Here, we will always distinguish between the
conditional statement p → q and the biconditional
statement p ↔ q

36
Precedence of Logical Operators
}  When multiple logical operators are used in the same
compound proposition, we follow the following
precedence order to understand it:
}  Note that all operators are right associative (conventionally)
}  Parentheses can also be used to disambiguate

}  Example: Operator Precedence

}  p ∨q → ¬r is equivalent to (p ∨q) → ¬r ¬ 1
∧ 2
}  If the intended meaning is p ∨(q → ¬r ) ,
∨ 3
then parentheses must be used
→ 4
↔ 5

37
Another Example
}  Parse the following propositional statement Op. Prec.
p ∧ ¬ q → p ∧ r ∨ s → ¬ t ↔ q ∨ s ¬ 1
∧ 2
∨ 3
→ 4
↔ 5






}  Note that all operators are right associative
}  Parentheses can also be used to disambiguate
38
Another Example
}  Parse the following propositional statement Op. Prec.
p ∧ ¬ q → p ∧ r ∨ s → ¬ t ↔ q ∨ s ¬ 1
∧ 2
p ∧ (¬ q) → p ∧ r ∨ s → (¬ t )↔ q ∨ s ∨ 3
→ 4
↔ 5






}  Note that all operators are right associative
}  Parentheses can also be used to disambiguate
39
Another Example
}  Parse the following propositional statement Op. Prec.
p ∧ ¬ q → p ∧ r ∨ s → ¬ t ↔ q ∨ s ¬ 1
∧ 2
p ∧ (¬ q) → p ∧ r ∨ s → (¬ t )↔ q ∨ s ∨ 3
(p ∧ (¬ q)) → (p ∧ r) ∨ s → (¬ t )↔ q ∨ s → 4
↔ 5






}  Note that all operators are right associative
}  Parentheses can also be used to disambiguate
40
Another Example
}  Parse the following propositional statement Op. Prec.
p ∧ ¬ q → p ∧ r ∨ s → ¬ t ↔ q ∨ s ¬ 1
∧ 2
p ∧ (¬ q) → p ∧ r ∨ s → (¬ t )↔ q ∨ s ∨ 3
(p ∧ (¬ q)) → (p ∧ r) ∨ s → (¬ t )↔ q ∨ s → 4
5
(p ∧ (¬ q)) → ((p ∧ r) ∨ s) → (¬ t )↔ (q ∨ s) ↔






}  Note that all operators are right associative
}  Parentheses can also be used to disambiguate
41
Another Example
}  Parse the following propositional statement Op. Prec.
p ∧ ¬ q → p ∧ r ∨ s → ¬ t ↔ q ∨ s ¬ 1
∧ 2
p ∧ (¬ q) → p ∧ r ∨ s → (¬ t )↔ q ∨ s ∨ 3
(p ∧ (¬ q)) → (p ∧ r) ∨ s → (¬ t )↔ q ∨ s → 4
5
(p ∧ (¬ q)) → ((p ∧ r) ∨ s) → (¬ t )↔ (q ∨ s) ↔
(p ∧ (¬ q)) → (((p ∧ r) ∨ s) → (¬ t ))↔ (q ∨ s)




}  Note that all operators are right associative
}  Parentheses can also be used to disambiguate
42
Another Example
}  Parse the following propositional statement Op. Prec.
p ∧ ¬ q → p ∧ r ∨ s → ¬ t ↔ q ∨ s ¬ 1
∧ 2
p ∧ (¬ q) → p ∧ r ∨ s → (¬ t )↔ q ∨ s ∨ 3
(p ∧ (¬ q)) → (p ∧ r) ∨ s → (¬ t )↔ q ∨ s → 4
5
(p ∧ (¬ q)) → ((p ∧ r) ∨ s) → (¬ t )↔ (q ∨ s) ↔
(p ∧ (¬ q)) → (((p ∧ r) ∨ s) → (¬ t ))↔ (q ∨ s)
((p ∧ (¬ q)) → (((p ∧ r) ∨ s) → (¬ t )))↔ (q ∨ s)



}  Note that all operators are right
associative
}  Parentheses can also be used to disambiguate
43
Another Example
}  Parse the following propositional statement Op. Prec.
p ∧ ¬ q → p ∧ r ∨ s → ¬ t ↔ q ∨ s ¬ 1
∧ 2
p ∧ (¬ q) → p ∧ r ∨ s → (¬ t )↔ q ∨ s ∨ 3
(p ∧ (¬ q)) → (p ∧ r) ∨ s → (¬ t )↔ q ∨ s → 4
5
(p ∧ (¬ q)) → ((p ∧ r) ∨ s) → (¬ t )↔ (q ∨ s) ↔
(p ∧ (¬ q)) → (((p ∧ r) ∨ s) → (¬ t ))↔ (q ∨ s)
((p ∧ (¬ q)) → (((p ∧ r) ∨ s) → (¬ t )))↔ (q ∨ s)
(((p ∧ (¬ q)) → (((p ∧ r) ∨ s) → (¬ t )))↔ (q ∨ s))


}  Note that all operators are right
associative
}  Parentheses can also be used to disambiguate

44
Truth Tables

45
Truth Tables For Compound Propositions
}  Rows
}  Need a row for every possible combination of values for the
atomic propositions
}  Columns
}  Need a column for the compound proposition (usually at far
right)
}  Need a column for the truth value of each expression that
occurs in the compound proposition as it is built up
}  This includes the atomic propositions

46
Example Truth Table
}  Construct a truth table for

p q r ¬r p ∨ q p ∨ q → ¬r
T T T F T F
T T F T T T
T F T F T F
T F F T T T
F T T F T F
F T F T T T
F F T F F T
F F F T F T

47
Equivalent Propositions
}  Two propositions are equivalent if they always have
the same truth value
}  Example:
}  Show using a truth table that the implication is equivalent
to the contrapositive: (p →q ) ⇔ (¬q → ¬ p)
}  Solution:

p q ¬ p ¬ q p →q ¬q → ¬ p
T T F F T T
T F F T F F
F T T F T T
F F T T T T

48
Using a Truth Table to Show Non-Equivalence
}  Example:
}  Show using truth tables that neither the converse nor
inverse of an implication are equivalent to the implication

}  Solution:

p q ¬ p ¬ q p →q ¬ p →¬ q q → p

T T F F T T T
T F F T F T T
F T T F T F F
F F T T T T T

49
Biconditional Truth Table
}  p ↔ q means that p and q have the same truth value
}  Note this truth table is the exact opposite of ⊕’s!
Thus, p ↔ q means ¬(p ⊕ q)
}  p ↔ q does not imply that p and q are true, or that
either of them causes the other, or that they have a
common cause

p q p⊕q ¬(p⊕q) p↔q


T T F T T
T F T F F
F T T F F
F F F T T
50
Exercise
}  How many rows are there in a truth table with n
propositional variables?

}  Solution: 2n

}  Note that this means that with n propositional
variables, we can construct 2n distinct (i.e., not
equivalent) propositions

51
Semantics of propositional formulae
}  A proposition is valid iff it evaluates to true in every
row of its truth table
}  A proposition is satisJiable iff it evaluates to true in
some row of its truth table
}  A proposition is valid iff its negation is not satisJiable
}  A proposition is a contingency iff it is satisJiable and its
negation is satisJiable
}  A proposition is a contradiction iff it evalutes to false in
every row of its truth table, i.e., iff its negation is valid


52
Any Questions?

53

You might also like