0% found this document useful (0 votes)
42 views

1 Logic Theory Part1

This document provides an introduction to discrete structures and propositional logic. It defines key concepts such as: - Discrete objects that can be separated from each other, like integers, versus continuous objects. - Discrete structures like sets, relations and graphs that are used to represent discrete objects. - Propositional logic as the basic building blocks of logic where propositions can be either true or false. - Logical operators like negation, conjunction, disjunction and implication that are used to combine propositions into compound propositions. - Truth tables that define the truth values of compound propositions based on the truth values of the individual propositions. The document explains that discrete structures are important for computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

1 Logic Theory Part1

This document provides an introduction to discrete structures and propositional logic. It defines key concepts such as: - Discrete objects that can be separated from each other, like integers, versus continuous objects. - Discrete structures like sets, relations and graphs that are used to represent discrete objects. - Propositional logic as the basic building blocks of logic where propositions can be either true or false. - Logical operators like negation, conjunction, disjunction and implication that are used to combine propositions into compound propositions. - Truth tables that define the truth values of compound propositions based on the truth values of the individual propositions. The document explains that discrete structures are important for computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 30

The Foundations: Logic and Proof

1
What is Discrete Structure?

 Discrete Objects
 Separated from each other (Opposite of continuous)
 e.g., integers, people, house,
 Vs. Continuous objects: e.g., real number

 Discrete Structures
 The abstract mathematical structures used to represent
discrete objects and relationships between the objects
e.g. sets, relations, graphs

2
Why do we study Discrete Structures?

 Information is stored and manipulated by computers in a


discrete fashion. 0101101…
 As a student in computer science major, you need to know
the basic language and conceptual foundation for all of the
computer science, i.e., Discrete Structures!
 Discrete structure concepts are also widely used
throughout math, science, engineering, economics, biology,
etc., …
 Get training for rational thought!

3
1.1 Propositional Logic
•Introduction
•Propositions
•Propositional Logic
• Negation
• Connectives ( conjunction – disjunction – exclusive OR)
• Conditional statements (implication)
• Converse, Contrapositive and Inverse
• Biconditional
•Truth tables of Compound Propositions
•Precedence of Logic Operators
4
•Logic and Bit Operations
Introduction
The rules of logic are used to distinguish between
valid and invalid mathematical arguments.
Logic has many applications to computer science.
Ex:
Computer circuits.
Construction of computer programs.

5
Propositions
The basic building blocks of logic.
It is a declarative sentence that is either True or
False, but not both.
Example 1 Example 2
1. Riyadh is the capital of 1. What time is it?
Saudi Arabia. 2. Read this
2. Cairo is the capital of carefully.
Lebanon. 3. x+1=2
3. 1+1=2 4. x+y=z
4. 2+2=3
All declarative sentences are Not propositions
propositions not declarative sentences 1+2
T–F–T–F neither true or nor false 3+4
6
Propositions
We use letters to denote propositional variables that
is used to represent propositions, just as letters used
to denote numerical variables.
The conventional letters used for propositions
variables are p, q, r, s…
The truth value if the proposition is true  T
The truth value if the proposition is false F
The area of logic that deals with proposition is
called the proposition calculus or propositional
logic.
7
Propositions
There are a methods for producing new
propositions from those what we have.
Many mathematical statement are constructed by
combining one or more propositions (compound
propositions) using logical operators.

8
Negation of a proposition
Definition1 :
Let p be a proposition. The negation of p, denoted by
p, is the statement “it is not the case that p”.
The proposition p is read “NOT p”
Negation construct a new proposition from a
single existing proposition.
The truth table for the negation of a proposition.

p p
Notice that p is a T F
proposition! F T
9
Negation of a proposition
Example 3:
Find the negation of the proposition
“Sara’s pc runs Linux” and express this in simple
English.

Solution:
Negation is: “it is not the case that Sara’s pc runs
Linux”
More simply: “Sara’s pc does not run Linux”

10
Negation of a proposition
Example 4:
Find the negation of the proposition
“Ahmad’s smart phone has at least 32 GB of memory” and
express this in simple English.

Solution:
Negation is: “Ahmad’s smart phone does not have at least32
GB of memory”
More simply: “Ahmad’s smart phone has less than 32 GB of
memory”

11
Conjunction of propositions
Definition2 :
Let p and q be propositions. The conjunction of p
and q, denoted by pq, is the proposition “p and
q”. The conjunction pq is true when both p and q
are true, and is false otherwise.
The truth table for the conjunction of two
proposition.
pq q p
Notice that conjunction T T T
can be between two or F F T
more propositions
F T F
F F F
12
Conjunction of propositions
Example 5:
Find the conjunction of the propositions p and q,
where p is the proposition “Ahmad’s pc has more than 16
GB free hard disk space”
and q is the proposition “The processor in Ahmad’s pc runs
faster than 1 GHz” express this in simple English.

Solution:
Ahmad’s pc has more than 16 GB free hard disk space and The
processor in Ahmad’s pc runs faster than 1 GHz.

To be true, both conditions given must be true. It is false when


one or both are false
13
Disjunction of propositions
Definition3:
Let p and q be propositions. The disjunction of p and
q, denoted by p  q, is the proposition “p or q”.
The conjunction p  q is false when both p and q
are false, and is true otherwise.
The truth table for the disjunction of two
proposition.
pq q p
Notice that disjunction T T T
can be between two or T F T
more propositions
T T F
14 F F F
Disjunction of propositions
Example 6:
Find the disjunction of the propositions p and q,
where p is the proposition “Ahmad’s pc has more than
16 GB free hard disk space”
and q is the proposition “The processor in Ahmad’s pc
runs faster than 1 GHz” express this in simple
English.

Solution:
Ahmad’s pc has more than 16 GB free hard disk space orThe
processor in Ahmad’s pc runs faster than 1 GHz.
When it will be true? False?
15
Exclusive-OR of propositions
Definition4:
Let p and q be propositions. The exclusive or of p
and q, denoted by p ⊕ q, is the proposition that is
true when exactly one of p and q is true and is false
otherwise.
The truth table for the exclusive or of two
proposition.
p⊕q q p
F T T
Notice it can be between
T F T
two or more propositions
T T F
16 F F F
Conditional Statement (Implication)
Definition5:
Let p and q be propositions. The conditional statement
(implication) p  q is the proposition “if p, then q”. The
conditional statement p  q is false when p is true and q is
false, otherwise true.
In the conditional statement p  q, p is called the
hypothesis or (antecedent or premise) and q is called the
conclusion or (consequence).
Comes in format:
If p, then q
If p, q
p is sufficient for q
p implies q
…
you will find rest of them in book. Look at them!
17
Conditional Statement (Implication)
The truth table for the implication of two proposition.

pq q p
T T T
F F T
T T F
Ex: T F F

“If you get 100% on the final, then you will get an A”.

Hypothesis Conclusion

18
Conditional Statement (Implication)
Example:
Hypothesis Conclusion

If Juan has a smart phone, then 2+3 = 5


 This proposition is true, because conclusion is true.

If Juan has a smart phone, then 2+3 = 6


 This proposition is true, if Juan does not have a
smart phone even though 2+3=6 is false.

There are no relation between hypothesis and


conclusion.
In programming we have if-then.
19
Conditional Statement (Implication)
Example:
Let p the statement “Maria learns discrete mathematics”
and q the statement “ Maria will find job”
Express the statement p  q as a statement in
English.

Solution:
 If Maria learns discrete mathematics, then she will find job.
 Maria will find job when she learns discrete mathematics.
Rest example in book page 7
When it will be true? False?

20
Converse, Contrapositive and Inverse
 Converse: q  p is converse of p  q.
 Ex.: p  q: “If it is noon, then I am hungry.”
q  p: “If I am hungry, then it is noon.”

 Contrapositive: q  p is contapositive of p  q.
 Ex.: q  p: “If I am not hungry, then it is
not noon.”

 Inverse: p  q is inverse of p  q.
 Ex.: p  q: “If it is not noon, then I am not
hungry.”
See
example
p  q has same truth values as q  p 7
21
Biconditional Statement
Definition6:
Let p and q be two propositions. The biconditional
statement (bi-implication) p ↔ q is the proposition “p
if and only if q”. The biconditional statement p ↔ q is
true when p and q have the same truth values,
otherwise false.
It corresponds to English “p if and only if q”.
The truth table of biconditional p↔q q p
T T T
F F T
F T F
T F F
22
Biconditional Statement
Example10:
p: “You can take the flight”
q : “You buy a ticket”

p ↔ q:
“You can take the flight if and only if you buy a
ticket”
 True if p and q both true or both false
 False otherwise

23
Implicit Biconditional Statement
 Not always explicit in natural language.
 Often expressed using an “if, then” or “only, if”
 Converse is implied but not stated.
Ex:
“if you finish your meal, then you can have dessert”

Means
“You can have dessert if and only if you finish your
meal”

24
Truth Table of Compound Proposition
 Used to build up complicated compound positions involving
any numbers of propositional variables.
 Construct truth table for (p  q) → (p  q).

(p  q) → (p  q) p  q p  q q q p
F F T T F F
F F T T F T
T F F F T F
T T T F T T
 Q3: Construct truth table for
 (p  q) ↔ (p  q). of raws = 2 # of variable #
25
 (p ⊕ q) → (p ⊕ q).
Precedence
 Precedence of Logical Operators:
Precedence Operator
1 ¬
2 Λ
3 ν
4 →
5 ↔

26
Propositional Logic – Translating English
Sentences
 The sentence “The automated reply cannot be sent
when the file system is full” can be translated as
q → p
where p: “The automated reply can be sent ”
q: “The file system is full”
 The sentence “You cannot drive a car if you are
under 4 feet tall unless you are older than 16 years
old” can be translated as
(q r) → p
where p: “You can drive a car ”
q: “You are under 4 feet tall ”
r: “You are older than 16 years old”

27 Prepared by Dr. Zakir H. Ahmed 09/03/22


Propositional Logic – Translating English
Sentences
 The sentence “You can access the Internet from
campus only if you are a computer science major or
you are not a freshman” can be translated as
p → (q  r)
where p: “You can access the Internet from campus”
q: “You are a computer science major”
r: “You are a freshman”
 Q4: Translate the following sentences into logical
expressions:
 “Access is granted whenever the user has paid
the subscription fee and enters a valid password”
 “If the user has not entered a valid password but
has paid the subscription fee, then access is
granted”
28 Prepared by Dr. Zakir H. Ahmed 09/03/22
Logic and Bit Operations
 Bit: A bit is a symbol with two possible values, namely, 0
(zero) and 1 (one).
 A bit can be used to represent a truth value as (1 for T) and (0
for F)
 Bit string: A bit string is a sequence of bits. The length of the
string is number of bits in the string.
 Example: 10101001 is a bit string of length eight
 We define the bitwise OR, AND, and XOR of two strings of
same length to be the strings that have as their bits the OR,
AND, and XOR of the corresponding bits in the two strings,
respectively.
 We use the symbols , , and ⊕ to represent bitwise OR,
AND, and XOR, respectively.
29
Logic and Bit Operations
Truth table for bitwise OR, AND, and XOR:
x⊕y xy xy
y x

0 0 0 0 0
1 0 1 1 0
1 0 1 0 1
0 1 1 1 1

Example 13
Find bitwise OR, AND, and XOR of the bit strings:
0110110110 and 1100011101

30

You might also like