0% found this document useful (0 votes)
9 views37 pages

Lecture 2

Uploaded by

defaltccc
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)
9 views37 pages

Lecture 2

Uploaded by

defaltccc
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/ 37

Lecture 2

The Foundations:
Logic and Proofs
Propositional Logic

• The rules of logic give precise meaning to mathematical


statements.

• These rules are used to distinguish between valid and invalid


mathematical arguments.

• Rules are used in the design of computer circuits, the


construction of computer programs, the verification of the
correctness of programs, and in many other ways.

• Software systems have been developed for constructing some,


but not all, types of proofs automatically.
Propositional Logic

A proposition is a declarative sentence (a sentence that declares a


fact) that is either true or false, but not both.

Are the following sentences propositions?

1. Male’ is the capital of Maldives. (Yes)

2. Barcelona is the capital of Spain. (No)

3. 1 + 2 = 3 (Yes)

4. 2 + 2 = 3 (No)
Propositional Logic
Consider the following sentences.

1. What time is it?

2. Read this carefully.

3. x + 1 = 2.

4. x + y = z.
Sentences 1 and 2 are not propositions because they are
not declarative sentences.
Sentences 3 and 4 are not propositions because they are
neither true nor false.
Sentences 3 and 4 can be turned into a proposition if we
assign values to the variables.
Propositional Logic

Propositional Logic (propositional calculus ) – the area of logic


that deals with propositions.

Propositional Variables (statement variables) – variables that


represent propositions, just as letters are used to denote numerical
variables: p, q, r, s

E.g. Proposition p – “Today is Friday.”

Truth values – T truth value of a proposition is true , F if it is a


false proposition.

Compound propositions- are formed from existing propositions


using logical operators.
Propositional Logic

DEFINITION 1

Let p be a proposition. The negation of p, denoted by ¬p


(also denoted by 𝑝),
̅ is the statement

“It is not the case that p.”

The proposition ¬p is read “not p.” The truth value of the


negation of p, ¬p is the opposite of the truth value of p.
Propositional Logic
Examples
Find the negation of the proposition “Today is Friday.” and
express this in simple English.
Solution: The negation is “It is not the case that today is Friday.”
In simple English, “Today is not Friday.” or “It is not
Friday today.”

Find the negation of the proposition “At least 10 inches of


rain fell today in Miami.” and express this in simple English.
Solution: The negation is “It is not the case that at least 10 inches
of rain fell today in Male’.”
In simple English, “Less than 10 inches of rain fell today in
Male’.”
Propositional Logic
Find the negation of the proposition

1) “Ahmed’s PC runs Linux” and express this in simple


English.
Solution: The negation is:
“It is not the case that Ahmed’s PC runs Linux.”
In simple English, “Ahmed’s PC does not run Linux“

2) Find the negation of the proposition “Vaail’s smartphone


has at least 32GB of memory.” and express this in simple
English.
Solution: The negation is “It is not the case that Vaail’s smartphone
has at least 32GB of memory’.”
In simple English, “Vaail’s smartphone has less than 32GB of
memory”
Propositional Logic
Table below displays the truth table for the negation of a
proposition p. This table has a row for each of the two possible
truth values of a proposition p. Each row shows the truth value of
¬p corresponding to the truth value of p for this row.
Truth table:
The Truth Table for the
Negation of a Proposition.
p ¬p
T F
F T

Logical operators are used to form new propositions from two or


more existing propositions.
The logical operators are also called connectives.
Propositional Logic
DEFINITION 2
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.

Example
Find the conjunction of the propositions p and q where p is
the proposition “Today is Friday.” and q is the proposition “It
is raining today.”, and the truth value of the conjunction.

Solution: The conjunction is the proposition “Today is Friday and it is raining


today.” The proposition is true on rainy Fridays.
Propositional Logic
Example
Find the conjunction of the propositions p and q where p is the
proposition “Rahma’s PC has more than 16 GB free hard disk
space” and q is the proposition “The processor in Rahma’s PC
runs faster than 1 GHz.”
Solution
The conjunction of these propositions, p ∧ q, is the proposition
“Rahma’s PC has more than 16 GB free hard disk space, and the
processor in Rahma’s PC runs faster than 1 GHz.” This
conjunction can be expressed more simply as “Rahma’s PC has
more than 16 GB free hard disk space, and its processor runs
faster than 1 GHz.” For this conjunction to be true, both
conditions given must be true. It is false, when one or both of
these conditions are false.
Propositional Logic
Table below displays the truth table of p ∧ q. This table has a row
for each of the four possible combinations of truth values of p and
q. The four rows correspond to the pairs of truth values TT, TF, FT,
and FF, where the first truth value in the pair is the truth value of p
and the second truth value is the truth value of q.

Truth table: The Truth Table for the


Conjunction of Two
Propositions.
p q pΛq
T T T
T F F
F T F
F F F
Propositional Logic
DEFINITION 3
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.

Example
“Students who have taken calculus or computer science can take
this class.” – those who take one or both classes.
exclusive or : The disjunction is true only when one of the
proposition is true.
Propositional Logic
Example
What is the disjunction of the propositions p and q where p and q
are the same propositions as in
“Rahma’s PC has more than 16 GB free hard disk space” and q is
the proposition “The processor in Rahma’s PC runs faster than 1
GHz.”

Solution
The disjunction of p and q, p ∨ q, is the proposition.
“Rahma’s PC has at least 16 GB free hard disk space, or the
processor in Rahma’s PC runs faster than 1 GHz.”
Propositional Logic
Table below displays the truth table of p ∨ q.

Truth table:
The Truth Table for the
Disjunction of Two
Propositions.
p q pνq
T T T
T F T
F T T
F F F
Propositional Logic
DEFINITION 4
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 Propositions.

p q pÅ q
T T F
T F T
F T T
F F F
Propositional Logic
DEFINITION 4
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 Propositions.

p q pÅ q
T T F
T F T
F T T
F F F
Propositional Logic
Conditional Statements

DEFINITION 5
The conditional statement p → q, is the proposition “if p,
then q.” The conditional statement is false when p is true
and q is false, and true otherwise. In the conditional
statement p → q, p is called the hypothesis (or antecedent or
premise) and q is called the conclusion (or consequence).

The statement p → q is called a conditional statement because


p → q asserts that q is true on the condition that p holds. A
conditional statement is also called an implication.
Propositional Logic

A conditional statement is also called an implication.

Example: “If I am elected, then I will lower taxes.” p → q


Think of it as a contract, obligation or pledge The contract is breached
(implication is false) only if the p is true and q is false. Otherwise the contract
(the pledge) is valid (true)

implication:
elected, lower taxes. T T |T
not elected, lower taxes. F T |T
not elected, not lower taxes. F F |T
elected, not lower taxes. T F |F
Propositional Logic
The truth table for the conditional statement p → q is shown in
Table given below.

The Truth Table for the


Conditional Statement
p → q.
p q p→q (implication is false) only if
the p is true and q is false.
T T T Otherwise is valid (true)
T F F
F T T
F F T
Propositional Logic
Example:
Let p be the statement “Maria learns discrete mathematics.”
and q be the statement “Maria will find a good job.” Express
the statement p → q as a statement in English.
(implication is false) only if the p is true and q is false.
Solution: Any of the following - Otherwise is valid (true)
“If Maria learns discrete mathematics, then she will find a
good job.
“Maria will find a good job when she learns discrete
mathematics.”
“For Maria to get a good job, it is sufficient for her to learn
discrete mathematics.”
“Maria will find a good job unless she does not learn
discrete mathematics.”
Propositional Logic
Example:
“If it is sunny, then we will go to the beach.”

the statement is true unless it is indeed sunny, but do not go to


the beach.
“If Leena has a smartphone, then 2 + 3 = 5”
“If Leena has a smartphone, then 2 + 3 = 6”

We would not use these last two conditional statements in natural


language (except perhaps in sarcasm), because there is no relationship
between the hypothesis and the conclusion in either statement.
The mathematical concept of a conditional statement is independent of a
cause-and- effect relationship between hypothesis and conclusion.
Propositional Logic
CONVERSE, AND INVERSE
We can form some new conditional statements starting with a
conditional statement p → q.

The proposition q → p is called the converse of p → q.

The proposition ¬p → ¬q is called the inverse of p → q.

We now show that neither the converse, q → p, nor the inverse,


¬p → ¬q, has the same truth value as p → q for all possible truth
values of p and q.

Note that when p is true and q is false, the original conditional


statement is false, but the converse and the inverse are both true.
Propositional Logic
CONTRAPOSITIVE

The contrapositive of p → q is the proposition ¬q → ¬p.

The contrapositive, ¬q → ¬p, of a conditional statement p → q


always has the same truth value as p → q.

To see this, note that the contrapositive is false only when


¬p is false and ¬q is true, that is, only when p is true and q is
false.
Propositional Logic
Example:
What are the contrapositive, the converse, and the inverse of the
conditional statement
“The home team wins whenever it is raining?” Contrapositive of p → q : ¬ q → ¬ p
Converse of p → q : q → p
Inverse of p → q : ¬ p → ¬ q

Solution: p → q, the original statement can be rewritten as


“If it is raining, then the home team wins.”
The contrapositive of this conditional statement is
“If the home team does not win, then it is not raining.”
The converse is
“If the home team wins, then it is raining.”
The inverse is
“If it is not raining, then the home team does not win.”
Propositional Logic

DEFINITION 6
Let p and q be propositions. The biconditional statement 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, and is false otherwise. Biconditional statements are
also called bi-implications.

The statement p ↔ q is called a biconditional statement.


p ↔ q has the same truth value as (p → q) Λ (q → p)
“if and only if” can be expressed by “iff”
Propositional Logic
The truth table for p ↔ q is shown in Table below. Note that the
statement p ↔ q is true when both the conditional statements p → q
and q → p are true and is false otherwise. That is why we use the
words “if and only if” to express this logical connective and why it
is symbolically written by combining the symbols → and ←.

The Truth Table for the


Biconditional p ↔ q
p q p↔q
T T T
T F F
F T F
F F T
Propositional Logic
Example:
Let p be the statement “You can take the flight,” and let q be the
statement “You buy a ticket.” Then p ↔ q is the statement
“You can take the flight if and only if you buy a ticket.”

Implication:
If you buy a ticket you can take the flight.
If you don’t buy a ticket you cannot take the flight.
Propositional Logic
Truth Tables of Compound Propositions

We can use connectives to build up complicated compound


propositions involving any number of propositional variables,
then use truth tables to determine the truth value of these
compound propositions.
Propositional Logic

Example:
Construct the truth table of the compound proposition
(p ν ¬q) → (p Λ q).

The Truth Table of (p ν ¬q) → (p Λ q).


p q ¬q p ν ¬q p Λ q (p ν ¬q) → (p Λ q)
T T F T T T
T F T T F F
? ? ? ?
F T F F F T
F F T T F F
Propositional Logic
• We can use parentheses to specify the order in which logical
operators in a compound proposition are to be applied.
• To reduce the number of parentheses, the precedence order is
defined for logical operators.

Precedence of Logical Operators


E.g.
Operator Precedence
¬p Λ q = (¬p ) Λ q
¬ 1
p Λ q V r = (p Λ q ) V r
Λ 2
p V q Λ r = p V (q Λ r)
ν 3
→ 4
↔ 5
Propositional Logic
Logic and Bit Operations

• Computers represent information using bits.


• A bit is a symbol with two possible values, 0 and 1.
• This meaning of the word bit comes from binary digit, because
zeros and ones are the digits used in binary representations of
numbers.
• By convention, 1 represents T (true) and 0 represents F (false).
• A variable is called a Boolean variable if its value is either true
or false.
• Bit operation – replace true by 1 and false by 0 in logical
operations.
Propositional Logic
Logic and Bit Operations

Table for the Bit Operators OR, AND, and XOR.


x y xVy xΛy xÅy
0 0 0 0 0
0 1 1 0 1
1 0 1 0 1
1 1 1 1 0

Information is often represented using bit strings, which are


lists of zeros and ones. When this is done, operations on the bit
strings can be used to manipulate this information.
Propositional Logic

DEFINITION 7
A bit string is a sequence of zero or more bits. The length of
this string is the number of bits in the string.

Example
101010011 is a bit string of length nine.
We can extend bit operations to bit strings. We define the bitwise OR, bitwise
AND, and bitwise XOR of two strings of the 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 it,
respectively.
Propositional Logic
Example
Find the bitwise OR, bitwise AND, and bitwise XOR of the bit
strings 0110110110 and 11 0001 1101.
(note: bit strings will be split into blocks of four bits to make them
easier to read)
Solution: The bitwise OR, bitwise AND, and bitwise XOR of these strings are
obtained by taking the OR, AND, and XOR of the corresponding bits, respectively.
This gives:

0 1 1 0 1 1 0 1 1 0
1 1 0 0 0 1 1 1 0 1
1 1 1 0 1 1 1 1 1 1 bitwise OR
0 1 0 0 0 1 0 1 0 0 bitwise AND
1 0 1 0 1 0 1 0 1 1 bitwise XOR
Propositional Logic
Example
Construct truth tables for the following
(p ∧ q) ∨ ¬ p

The Truth Table of (p ∧ q) ∨ ¬ p


p q ¬p pΛq (p ∧ q) ∨ ¬ p
T T F T T
T F F F F
F T T F T
F F T F T
Propositional Logic
Example
Construct truth tables for the following
((p ∧ (q ∧ r)) → ((p ∧ q) ∧ r)) Only case that’s
False is T à F = F
p q r q∧r p∧q p ∧ (q ∧ r) (p ∧ q) ∧ r ((p ∧ (q ∧ r)) → ((p ∧ q) ∧ r))

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

You might also like