Chapter1 - Part1 - Logic
Chapter1 - Part1 - Logic
(PART I)
FUNDAMENTAL
S OF LOGIC
LEARNING OUTCOME
Rules of Inference
PROPOSITIONS
Sit down!
Examples that are What time is it?
not propositions x+1=2
x+y=z
PROPOSITIONAL LOGIC
Constructing Propositions
Propositional Variables: p, q, r, s, …
The proposition that is always true is denoted by T and the proposition that is always
false is denoted by F.
Compound Propositions; constructed from logical connectives and other propositions
Negation ¬
Conjunction ∧
Disjunction ∨
Implication →
Biconditional ↔
COMPOUND PROPOSITIONS: NEGATION
p ¬p
T F
F T
Example: If p denotes “The earth is round.”, then ¬p denotes “It is not the case
that the earth is round,” or more simply “The earth is not round.”
COMPOUND PROPOSITIONS: CONJUNCTION
p q p →q
T T T
T F F
F T T
F F T
In p →q there does not need to be any connection between the antecedent or the
consequent.
The “meaning” of p →q depends only on the truth values of p and q.
These implications are perfectly fine, 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 the moon is made of green cheese then I’m on welfare.”
“If 1 + 1 = 3, then your grandma wears combat boots.”
UNDERSTANDING IMPLICATION (CONT..)
If the politician is elected and does not lower taxes, then the voters can say that
he or she has broken the campaign pledge.
UNDERSTANDING IMPLICATION (CONT..)
Case Study:
“If I am elected, then I will lower taxes.”
p q p →q
T – Elected T – lower taxes T
T – Elected F – not lower taxes F
F – Not elected T – lower taxes T
F – Not elected F – not lower taxes T
UNDERSTANDING IMPLICATION (CONT..)
Case Study:
“If you score 80% or above for Discrete Structure, then you will get an A.”
p q p →q
T – score 80% T – grade A T
T – score 80% F – grade B F
F – score below 80% T – grade A T
F – score below 80% F – grade B T
Example: Find the converse, inverse, and contrapositive of “It is raining is a sufficient
condition for my not going to town.”
Solution:
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.
COMPOUND PROPOSITIONS: BICONDITIONAL
p q p ↔q
T T T
T F F
F T F
F F T
p q r r pq p q → r
T T T F T F
T T table for F
Construct a truth 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
EQUIVALENT PROPOSITIONS
Two propositions are equivalent if they always have the same truth value.
Example: Show using a truth table that p →q is equivalent to the
contrapositive ¬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
USING A TRUTH TABLE TO SHOW NON-
EQUIVALENCE
Example: Show using truth tables that neither the converse nor inverse of an
implication are not 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
PRECEDENCE OF LOGICAL OPERATORS
Operator Precedence
1
2
3
4
5
p q r is equivalent to (p q) r
Translating English
System
to Propositional
Specifications
Logic
Logic has many important applications in computer science and numerous other
disciplines
For example:
Logic is used in the specification of software and hardware
Rule of logic can be used to design computer circuits, to construct
computer programs, to verify the correctness of programs, and to build
expert systems
Logic can be used to analyze and solve many familiar puzzles
TRANSLATING ENGLISH SENTENCES
Solution: Let a, c, and f represent respectively “You can access the internet from
campus,” “You are a computer science major,” and “You are a freshman.”
a→ (c ∨ ¬ f )
SYSTEM SPECIFICATIONS
Translating sentences from natural language into logical expressions is an essential part of
specifying both hardware and software systems
System specification should be consistent, that is they should not contain conflicting
requirements that could be used to derive a contradiction.
When specifications are not consistent, there would be no way to develop a system that satisfies
all specifications
q→ ¬ p
CONSISTENT SYSTEM SPECIFICATIONS
Most Web search engines support Boolean searching techniques, which usually
can help find Web pages about particular subjects.
Eg. Use Boolean searching to find Web pages about universities in New Mexico.
Look for pages matching NEW AND MEXICO AND UNIVERSITIES.
The results of this search will include those pages that contain the three words
NEW, MEXICO, and UNIVERSITIES. This will include all of the pages of
interest, together with others such as a page about new universities in
Mexico.
Note: In Google, and many other search engines, the word “AND” is not needed, although it is understood,
because all search terms are included by default. These search engines also support the use of quotation marks to
search for specific phrases. So, it may be more effective to search for pages matching “New Mexico” AND
UNIVERSITIES.)
WEB PAGE SEARCHING
Eg. Find pages that deal with universities in New Mexico or Arizona.
Search for pages matching (NEW AND MEXICO OR ARIZONA) AND
UNIVERSITIES.
(Note: Here the AND operator takes precedence over the OR operator. Also, in
Google, the terms used for this search would be NEW MEXICO OR ARIZONA.)
The results of this search will include all pages that contain the word
UNIVERSITIES and either both the words NEW and MEXICO or the word
ARIZONA.
Again, pages besides those of interest will be listed.
WEB PAGE SEARCHING
Eg. Find Web pages that deal with universities in Mexico (and not New Mexico).
Look for pages matching MEXICO AND UNIVERSITIES, but because the results
of this search will include pages about universities in New Mexico, as well as
universities in Mexico, it might be better to search for pages matching (MEXICO
AND UNIVERSITIES) NOT NEW.
The results of this search include pages that contain both the words MEXICO and
UNIVERSITIES but do not contain the word NEW.
Note: (In Google, and many other search engines, the word “NOT” is replaced by the symbol “-”. In Google,
the terms used for this last search would be MEXICO UNIVERSITIES -NEW.)
LOGIC CIRCUITS
The inverter (NOT gate)takes an input bit and produces the negation of that bit.
The OR gate takes two input bits and produces the value equivalent to the disjunction of the two
bits.
The AND gate takes two input bits and produces the value equivalent to the conjunction of the two
bits.
More complicated digital circuits can be constructed by combining these basic circuits to produce the
desired output given the input signals by building a circuit for each piece of the output expression and
then combining them. For example:
LOGIC PUZZLES
An island has two kinds of inhabitants, knights, who always tell the truth, and
knaves, who always lie.
Raymond
You go to the island and meet A and B.
Smullyan
A says “B is a knight.” (Born 1919)
B says “The two of us are of opposite types.”
p ¬p p ∨¬p p ∧¬p
T F T F
F T T F
LOGICALLY EQUIVALENT
Hence, p → q ≡ ¬p ∨ q
DE MORGAN’S LAWS
Augustus De Morgan
First Law
1806-1871
Second Law
Identity Laws: ,
Domination Laws: ,
Idempotent laws: ,
Negation Laws: ,
KEY LOGICAL EQUIVALENCES (CONT)
Commutative Laws: ,
Associative Laws:
Distributive Laws:
Absorption Laws:
MORE LOGICAL EQUIVALENCES
EQUIVALENCE PROOFS
0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1
EXAMPLE
p q p p q pq
0 0 1 1 1
0 1 1 1 1
1 0 0 0 0
1 1 0 1 1
s1 s2
logically equivalent
EXAMPLE
Solution:
[( p q ) r ] [ ( p q ) r ]
[( p q ) r ] ( p q ) r
( p q ) r
SIMPLIFICATION COMPOUND
STATEMENT