Discreet Structure
Discreet Structure
Winter 2008
Lecture 1
Propositional Logic
About the course
• From the CSE catalog:
– CSE 321 Discrete Structures (4)
Fundamentals of set theory, graph theory,
enumeration, and algebraic structures, with
applications in computing. Prerequisite: CSE
143; either MATH 126, MATH 129, or MATH
136.
• What I think the course is about:
– Foundational structures for the practice of
computer science and engineering
Why this material is important
• Language and formalism for expressing
ideas in computing
• Fundamental tasks in computing
– Translating imprecise specification into a
working system
– Getting the details right
Topic List
• Logic/boolean algebra: hardware design,
testing, artificial intelligence, software
engineering
• Mathematical reasoning/induction: algorithm
design, programming languages
• Number theory/probability: cryptography,
security, algorithm design, machine learning
• Relations/relational algebra: databases
• Graph theory: networking, social networks,
optimization
Administration
• Instructor • Homework
– Richard Anderson – Due Wednesdays (starting
• Teaching Assistant Jan 16)
– Natalie Linnell • Exams
• Quiz section – Midterms, Feb 8
– Thursday, 12:30 – 1:20, or – Final, March 17, 2:30-4:20
1:30 – 2:20 pm
– CSE 305 • All course information
• Recorded Lectures posted on the web
– Available on line • Sign up for the course
• Text: Rosen, Discrete mailing list
Mathematics
– 6th Edition preferred
– 5th Edition okay
Propositional Logic
Propositions
• A statement that has a truth value
• Which of the following are propositions?
– The Washington State flag is red
– It snowed in Whistler, BC on January 4, 2008.
– Hillary Clinton won the democratic caucus in Iowa
– Space aliens landed in Roswell, New Mexico
– Ron Paul would be a great president
– Turn your homework in on Wednesday
– Why are we taking this class?
– If n is an integer greater than two, then the equation an + bn = cn has no
solutions in non-zero integers a, b, and c.
– Every even integer greater than two can be written as the sum of two
primes
– This statement is false
– Propositional variables: p, q, r, s, . . .
– Truth values: T for true, F for false
Compound Propositions
• Negation (not) p
• Conjunction (and) pq
• Disjunction (or) pq
• Exclusive or pq
• Implication pq
• Biconditional pq
Truth Tables
p p p q pq
p q pq p q pq
Understanding complex
propositions
• Either Harry finds the locket and Ron
breaks his wand or Fred will not open a
joke shop
Understanding complex
propositions with a truth table
h r f hr f (h r) f
Aside: Number of binary
operators
• How many different binary operators are
there on atomic propositions?
p q pq
pq
• Implication
– p implies q
– whenever p is true q must be true
– if p then q
– q if p
– p is sufficient for q
– p only if q
If pigs can whistle then horses
can fly
Converse, Contrapositive,
Inverse
• Implication: p q
• Converse: q p
• Contrapositive: q p
• Inverse: p q
p q pq
English and Logic
• You cannot ride the roller coaster if you
are under 4 feet tall unless you are older
than 16 years old
– q: you can ride the roller coaster
– r: you are under 4 feet tall
– s: you are older than 16
Logical equivalence
• Terminology: A compound proposition is a
– Tautology if it is always true
– Contradiction if it is always false
– Contingency if it can be either true or false
pp
(p p) p
ppqq
(p q) p
(p q) (p q) ( p q) ( p q)
Logical Equivalence
• p and q are Logically Equivalent if p q is
a tautology.
• The notation p q denotes p and q are
logically equivalent
• Example: (p q) ( p q)
p q pq p pq (p q) ( p q)
Computing equivalence
• Describe an algorithm for computing if two
logical expressions are equivalent
• What is the run time of the algorithm?
Understanding connectives
• Reflect basic rules of reasoning and logic
• Allow manipulation of logical formulas
– Simplification
– Testing for equivalence
• Applications
– Query optimization
– Search optimization and caching
– Artificial Intelligence
– Program verification
Properties of logical connectives
• Identity
• Domination
• Idempotent
• Commutative
• Associative
• Distributive
• Absorption
• Negation
De Morgan’s Laws
• (p q) p q
• (p q) p q
• x (Even(x) Odd(x))
• x Greater(x+1, x)
• x (Even(x) Prime(x))
Statements with quantifiers
• x y Greater (y, x)
For every number there is some number that is greater than it
• y x Greater (y, x)
• x y (Greater(y, x) Prime(y))
Even(x)
Odd(x)
Prime(x)
Greater(x,y)
Equal(x,y)
Domain:
Positive Integers
Systems vulnerability
Reasoning about machine status
• Specify systems state • Predicates
and policy with logic
– Formal domain – RunsOS(M, O)
• reasoning about security – Vulnerable(M)
• automatic
implementation of – OSVersion(M, Ve)
policies
– LaterVersion(Ve, Ve)
• Domains
– Machines in the – Unpatched(M)
organization
– Operating Systems
– Versions
– Vulnerabilities
– Security warnings
System vulnerability statements
• Unpatched machines are vulnerable
x y P(x,y)
x y P(x,y)
x y P(x, y)
y x P(x, y)