Chapter0-1(Sec 0-3)
Chapter0-1(Sec 0-3)
Its Applications
College of Software
Engineering
Sichuan university
Haixian zhang(Melody)
Kinds of Problems Solved Using Discrete
Mathematics
What is the shortest path between two cities using a transportation
system?
Find the shortest tour that visits each of a group of cities only once and
then ends in the starting city.
How can we prove that there are infinitely many prime numbers?
How can a list of integers be sorted so that the integers are in increasing
order?
How can it be proved that a sorting algorithm always correctly sorts a list?
Kinds of Problems Solved Using Discrete
Mathematics
Course Requirement
induction calculus
logic
The problems and the techniques are often different (e.g. induction,
recursion).
Discrete Mathematics is a Gateway
Course
Topics in discrete mathematics will be important in many courses that
you will take in the future:
Computer Science: Computer Architecture, Data Structures,
Algorithms, Programming Languages, Compilers, Computer Security,
Databases, Artificial Intelligence, Networking, Graphics, Game Design,
Theory of Computation, ……
Reference: 《离散数学及其应用》 6th edition )
( Discrete Mathematical and Its Applications ),
Kenneth H.Rosen
袁崇义 屈婉玲 等译 机械工业出版社( 2011.7 )
《离
》 ( 机械工业出版社 )
学
数
散
冯伟森、栾新成、石兵编( 2011.3 )
Course Content
Attendance+ Homework, 30%
Midterm, 20%
Final Exam, 50%
1
Chapter
The Foundations: Logic and
Proofs
Logic puzzle
An island has two kinds of inhabitants,
knights, who always tell the truth, and
knaves, who always lie.
You go to the island and meet A and B.
A says “B is a knight.”
B says “The two of us are of opposite
types.”
question What are the types of A and B?
Both are Knaves
Chapter
Summary
Propositional Logic
propositional adj. 命题的
The Language of Propositions
(Proposition n. 命题 )
Applications
Logical Equivalences predicate ['predɪkeɪt] n. 〔数〕谓词 ;
Predicate Logic 〔语〕谓语 ; 〔逻〕谓项
The Language of Quantifiers
quantifier
Logical Equivalences ['kwɑntə.faɪər] n. 【逻辑学】限
Nested Quantifiers 量词nested [nestɪd] adj. 嵌套的
Proofs
Rules of Inference
Proof Methods
Proof Strategy proof strategy 证明策略
Propositional Logic
Summary
The Language of Propositions
Connectives
Truth Values
Truth Tables
Applications
Translating English Sentences
System Specifications
Logic Puzzles
Logic Circuits
Logical Equivalences
Important Equivalences
Showing Equivalence
Satisfiability
Section
1.1
Propositional
Logic
The propositional logic was first
developed systematically by
Aristotle
ARISTOTLE (384 b.c.e.–322
b.c.e.)
Aristotle was born in Stagirus (Stagira) in northern
Greece.
1+0=1
c) Toronto is the capital of Canada. Trenton ['trentən]
d)
0+0=2
n. 特伦顿(美国新泽西州首府)
e)
Toronto [tə'rɔntəu]
Examples that are not propositions.n. 多伦多(加拿大城市)
a) Sit down!
b) What time is it?
c) x+1=2
d) x+y=z
Propositional
Logic
GEORGE BOOLE (1815–1864)
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 ¬ negation
Conjunction ∧
[nə'ɡeɪʃ(ə)n] n. 否定,命题的
Disjunction ∨
否定
conjunction [kən'dʒʌŋkʃ(ə)n] n. 合取
Implication → disjunction n. 析取
Biconditional ↔ implication [.ɪmplɪ'keɪʃ(ə)n] n. 蕴含
Compound
Propositions:
Negation
The negation of a proposition p is denoted by
¬p and has this truth table:
p ¬p
T F
F T
p q p →q
T T T
T F F
F T T
q is false.
Understanding Implication (cont)
The if-then construction used in many
programming languages is different
from that used in logic.
Example: “if p then S”
p is a proposition
and S is a program segment
Different Ways of Expressing p
→q
if p, then q p implies q
if p, q p only if q
q unless ¬p q when p
q if p q when p
q whenever p p is sufficient for
q
q follows from p q is necessary for p
( 1 ) q→p
( 2 ) p→q 或~ q→ ~ p
( 3 ) p→q 或~ q→ ~ p
39
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 ¬p ¬q p →q ¬ p →¬ q→p
Solution:
q
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 F T T
Problem
How many rows are there in a truth table
with n propositional variables?
p q r is equivalent to (p q)
r )/pə'renθəsi:z/
Parentheses
圆括号,插入语then parentheses must be used.
precedence ['presɪdəns] n.
优先级
Section
1.2
Applications of
Propositional Logic
Summary--Applications of
Propositional Logic
Translating English to Propositional
Logic
System Specifications
Boolean Searching(Optional)
Logic Puzzles
Logic Circuits
AI Diagnosis Method (Optional)
specification
[.spesɪfɪ'keɪʃ(ə)n] n. 规范说明
Translating English
Sentences
Steps to convert an English sentence to
a statement in propositional logic
Identify atomic propositions and represent
using propositional variables.
Determine appropriate logical connectives.
“If I go swimming or to the country, I
will not go shopping.”
p: I go to Harry’s
q: I go to the country.
r: I will go shopping. If p or q then not
r.
Example
Problem: Translate the following sentence
into propositional logic:
“You can access the Internet from campus
only if you are a computer science major or
you are not a freshman.”
One Solution: Let a, c, and f represent
respectively “You can access the internet
from campus,” “You are a computer
a→ (c ∨ ¬ f )
science major,” and “You are a freshman.”
Exercise
You can not ride the roller coaster if
you are not 4 feet tall unless you are
older than 16 years old.
How can this English sentence be
translated into a logical expression.
q: You can not ride the roller
coaster
r: you are not 4 feet tall
s: you are older than 16 years old
System Specifications
System and Software engineers take
requirements in English and express them
in a precise specification language based
on logic.
Example: Express in propositional logic:
“The automated reply cannot be sent when
the file system is full”
Solution: One possible solution: Let p
denote “The automated reply can be sent”
q→ ¬ p
and q denote “The file system is full.”
Consistent System Specifications
Puzzles Raymond
Smullyan
(Born 1919)
Propositional Equivalences
Section
Summary
Tautologies, Contradictions, and Contingencies.
Logical Equivalence
Important Logical Equivalences
Propositional Satisfiability
Sudoku Example
Tautologies, Contradictions, and
Contingencies
A tautology is a proposition which is always
Example: p ∨¬p
true.
q.
p q ¬p ¬p ∨ q p→ q
T T F T T
T F F F F
F T T T T
F F T T T
De Morgan’s Laws
Augustus De
Morgan
1806-
1871
Domination Laws:
Idempotent laws:
Negation Laws:
Key Logical Equivalences (cont)
Commutative Laws: ,
Associative Laws:
Distributive Laws:
Absorption Laws:
More Logical Equivalences
Constructing New Logical
Equivalences
We can show that two expressions are logically
equivalent by developing a series of logically
equivalent statements.
To prove that we produce a series of
equivalences beginning with A and ending with
B.
No
(p ∨q)→¬r
Form (DNF) of
(¬ p∧ ¬ q) ∨ ¬r
is false or when both p and q are false.
Conjunctive Normal Form
A compound proposition is in Conjunctive
Normal Form (CNF) if it is a conjunction of
disjunctions.
Every proposition can be put in an equivalent
CNF.
Conjunctive Normal Form (CNF) can be
obtained by eliminating implications, moving
negation inwards and using the distributive
and associative laws.
Important in resolution theorem proving used
in artificial Intelligence (AI).
A compound proposition can be put in
conjunctive normal form through repeated
Conjunctive Normal Form
Example: Put the following into
CNF:
Solution:
1. Eliminate implication signs: