0% found this document useful (0 votes)
44 views51 pages

w1,2 - Ch01-1 Propositional Logic - Print

This document provides an overview of discrete structures and propositional logic. It begins with an introduction to logic and why it is important, particularly for mathematical reasoning, program design, and computer circuit design. The main concepts covered include: propositional logic and how it combines propositions using logical operators like negation, conjunction, disjunction, implication, and biconditional. Truth tables are used to define the operators. Applications discussed include translating English sentences into logical statements and designing logic circuits. The document concludes with questions about constructing truth tables.

Uploaded by

sssad
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)
44 views51 pages

w1,2 - Ch01-1 Propositional Logic - Print

This document provides an overview of discrete structures and propositional logic. It begins with an introduction to logic and why it is important, particularly for mathematical reasoning, program design, and computer circuit design. The main concepts covered include: propositional logic and how it combines propositions using logical operators like negation, conjunction, disjunction, implication, and biconditional. Truth tables are used to define the operators. Applications discussed include translating English sentences into logical statements and designing logic circuits. The document concludes with questions about constructing truth tables.

Uploaded by

sssad
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/ 51

Discrete

Structures
Instructor:
Assoc. Prof. Ahmed Sherif Zekri

Slides are mainly adapted from the book slides

1
Let’s get started with...

Logic!

2
Why logic?
• The rules of logic specify the meaning of
mathematical statements.
e.g.
“There exists an integer that is not the
sum of two squares”

3
Propositional Logic
• Crucial for mathematical reasoning
• Important for program design
• Applied in computer circuits design

• (Propositional) Logic is a system based on


propositions.
• A proposition is a (declarative) statement
that is either true (1) or false (0) (not both).

4
The Statement/Proposition Game

“Elephants are bigger than mice.”

Is this a statement? yes

Is this a proposition? yes

What is the truth value


of the proposition? true

5
Combining Propositions

One or more propositions can be combined


to form a single compound proposition.

We formalize this by denoting propositions


with letters such as p, q, r, s, and
introducing several logical operators.

6
Logical Operators (Connectives)
Negation (NOT, )
• Conjunction (AND, )
• Disjunction (OR,)
• Exclusive-or (XOR,  )
• Implication (if – then, → )
• Biconditional (if and only if,  )

Truth tables can be used to show how these


operators can combine propositions to form
compound propositions. 7
Negation (NOT)

Unary Operator, Symbol: 

P  P
true (T) false (F)
false (F) true (T)

8
Conjunction (AND)
Binary Operator, Symbol: 
P Q P Q
T T T
T F F
F T F
F F F

9
Disjunction (OR)
Binary Operator, Symbol: 
P Q P Q
T T T
T F T
F T T
F F F

10
Exclusive Or (XOR)
Binary Operator, Symbol: 
P Q PQ
T T F
T F T
F T T
F F F

11
Implication (if - then)
Binary Operator, Symbol: →
P Q P→Q
T T T
T F F
F T T
F F T

12
Biconditional (if and only if)
Binary Operator, Symbol: 
P Q PQ
T T T
T F F
F T F
F F T

p → qq → p 13
Statements and Operators
Statements and operators can be combined in any
way to form new statements.

P Q P Q (P)(Q)
T T F F F
T F F T T
F T T F T
F F T T T

14
Statements and Operations
Statements and operators can be combined in any
way to form new statements.

P Q PQ (PQ) (P)(Q)


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

15
Boolean operators summary
not not and or xor conditional Bi-
conditional
p q p q pq pq pq p→q pq
T T F F T T F T T
T F F T F T T F F
F T T F F T T T F
F F T T F F F T T
Precedence of operators
Just as in algebra, operators have
precedenc
e.g. 4+3*2 = 4+(3*2), not (4+3)*2
Precedence order (from highest to
lowest):
¬→↔
e.g. p  q  ¬r → s ↔ t yields:
(p  (q  (¬r)) → s) ↔ (t)
¬ is always performed before any other
operation
Logic and Bit Operations
Computers represent information using bits:
0 (T) and 1 (F).
A variable is called a Boolean variable if its
value is either true or false.
Computer bit operations correspond to the
logical connectives.

¬   

18
Example

19
Applications of Propositional Logic

• Logic circuits
• Translating English Sentences

20
Logic Circuits

Propositional logic can be applied to


the design of computer hardware
A logic circuit (or digital circuit)
receives input signals p1, p2, . . . ,
pn, each a bit [ 0 (off) or 1 (on)],
and produces output signals s1,
s2, . . . , sn, each a bit.
21
Example

(p ∧¬q) ∨ ¬r

Determine the output for the combinatorial circuit in


Figure 2. 22
Application of negation
The negation ¬ is used to find the
binary code of a positive integer!
Get the 2’s complement of an integer to
know its negative value.
Example: 01012 = 5
Find its negative -5:
Negate 5 then add 1
10102 + 1 = 10112)
23
1bit adder

24
Translating English
Sentences
* If the moon is out and it is not snowing, then
Ali goes out for a walk.
( t  u ) → s

* If it is snowing and the moon is not out, then Ali


will not go out for a walk.
( u  t ) → s
s: Ali goes out for a walk.
t: The moon is out.
u: It is snowing.
Translating English
Sentences
– p : “It is below freezing”
– q : “It is snowing”

It is below freezing and it is snowing


It is below freezing but not snowing
It is not below freezing and it is not snowing
It is either snowing or below freezing (or both)
pq
p  ¬q
¬p  ¬q
pq
Cont.
– p : “It is below freezing”
– q : “It is snowing”

If it is below freezing, it is also snowing


It is either below freezing or it is snowing,
but it is not snowing if it is below freezing
That it is below freezing is necessary and
sufficient for it to be snowing
p→q

(pq) (p→¬q)

p↔q
Equivalent Statements
P Q (PQ) (P)(Q) (PQ)  (P)(Q)

T T F F T
T F T T T
F T T T T
F F T T T
The statements (PQ) and (P)  (Q) are logically
equivalent, since they have the same truth table, or put
it in another way, (PQ) (P)  (Q) is always true.
28
Equivalence
Definition: two propositional statements
S1 and S2 are said to be (logically)
equivalent, denoted S1  S2 if
– They have the same truth table,
or
– S1  S2 is a tautology

29
Equivalence Laws
– Identity law, P  T  P,
– Domination law, P  F  F,
– Idempotent law, P  P  P,
– Double negation law,  ( P)  P
– Commutative law, P  Q  Q  P,
– Associative law, P  (Q  R) (P  Q)  R,
– Distributive law, P  (Q  R) (P  Q)  (P  R),
– De Morgan’s law,  (PQ)  ( P)  ( Q)
– Law with implication P→ Q PQ

30
31
32
Constructing New Logical Equivalences

Equivalences in Tables 6,7,8 can be


used to construct additional logical
equivalences.

Example:
Show that: ¬(p → q) and p ∧¬q are
logically equivalent.

33
Way1: By truth table
p q ¬q p→ q ¬(p→ q) p ¬ q
T T F T F F

T F T F T T

F T F T F F

F F T T F F

34
Way1: By truth table
p q ¬q p→ q ¬(p→ q) p ¬ q
T T F T F F

T F T F T T

F T F T F F

F F T T F F

35
Way2
• Use logical identities that we
already know to establish new logical
identities (e.g. Tables 6,7,8),
• This way is of practical importance
for establishing equivalences of
compound propositions with a large
number of variables.
• difficult to draw truth tables in this case!

36
Start with one of the two statements
and try to get the other statement:
¬(p → q)
≡ ¬(¬p ∨ q) Law of implication

≡ ¬(¬p)∧¬q Law of double negation

≡ p ∧¬q
37
Exercise
Show that ¬(p ∨ (¬p ∧ q)) and ¬p ∧¬q are
logically equivalent by developing a series
of logical equivalences.

38
Questions
Q1: How many rows are required
to construct the truth-table of:
[(p ∨ q) ∧ (p → r) ∧ (q → r)] → r

Q2: How many rows are required


to construct the truth table of a
proposition involving n atomic
propositions?
39
40
Fundamentals of Logic
• A compound proposition that is always true, no
matter what the truth values of the
propositional variables that occur in it, is called
a tautology.
• A compound proposition that is always false is
called a contradiction.
• A compound proposition that is neither a
tautology nor a contradiction is called a
contingency.
p ∨ ¬p : tautology
p  ¬p : contradiction
Tautology example

Demonstrate that
[¬p (p q )]→q
is a tautology.
There are two ways:
1. Construct a truth table and show
that [¬p (p q )]→q is
always true
2. Using a proof (apply rules).
42
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T

T F

F T

F F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F

T F F

F T T

F F T
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F T

T F F T

F T T T

F F T F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F T F

T F F T F

F T T T T

F F T F F
Tautology by truth table
p q ¬p p q ¬p (p q ) [¬p (p q )]→q
T T F T F T

T F F T F T

F T T T T T

F F T F F T
Derivational Proof
Techniques
Use derivational proof techniques to
show that the proposition
(p →p )  ((s  r)t) )  (q →r )
is a tautology.

48
L3
Derivational Proof
Techniques

(p →p )  ((s  r)t )) 
(q→r )
≡ T  ((sr)t ))  (q→r )
≡ T

49
L3
Example

Prove that: (p  q)  q  p  q

(p  q)  q  (p  q)  q DeMorgan’s

 (p  q)  q Double negation

 p  (q  q) Associativity

 p  q Idempotent
Tautology by proof
Prove that [¬p (p q )]→q is a tautology.
 [(¬p p)(¬p q)]→q Distributive Law
 [ F  (¬p q)]→q Negation Law
 [¬p q ]→q Identity Law
 ¬ [¬p q ]  q Implication Law
 [¬(¬p) ¬q ]  q DeMorgan Law
 [p  ¬q ]  q Double Negation
 p  [¬q q ] Associative Law
 p  [q ¬q ] Commutative Law
pT Negation Law
T Domination Law
51
L3

You might also like