2007Discrete
The foundationsCounting theory
Number theory
Graphs & trees
structures2110200
Evaluation
The foundations 15 %
Counting theory 15 %
Number theory 15 % Graphs & trees 15 %
Final 40 %
Motivation
3 4 6 7 8 5 3 22 7 8 5 1 4 8 4 +---
---
---
---
---
---
---
---
6 2 5 3 0 0 1 6How fast can we do the computation ?
Motivation
?A
I J
B
C
G
E D
H
F
Motivation
K = 0FOR I1 = 0 TO M {
FOR I2 = 0 TO I1 {FOR I3 = 0 TO I2 {
…
FOR In = 0 TO In-1 {K = K + 1
}…
}}
} Find the value of K
sThe Foundation
Relational structures
T s
The Foundations
Logic and reasoningSet, relation and function
Methods of proof
Logic & Reasoning
Historical
SYLLOGISTIC REASONINGSYLLOGISTIC REASONINGAristotle (384-322 B.C.)Aristotle (384-322 B.C.)
Euclid of Alexandria (325-265 Euclid of Alexandria (325-265 B.C.)B.C.)
DEDUCTIVE REASONINGDEDUCTIVE REASONING
Chrysippus of Soli (279-206 B.C.)Chrysippus of Soli (279-206 B.C.) MODAL LOGICMODAL LOGIC
George Boole (1815-1864 A.D.)George Boole (1815-1864 A.D.) PROPOSITIONAL LOGICPROPOSITIONAL LOGIC
Augustus De Morgan (1806-1871 A.D.)Augustus De Morgan (1806-1871 A.D.) DE MORGAN’s LAWsDE MORGAN’s LAWs
Propositional logic
Definition
A proposition is a declarative statement that is either true or false but not both.
Summary
Theorem : Logical Equivalences,
given any propositions p,q and r, a tautology T and a contradiction C, the following logical equivalences hold:
•Commutative laws: pq qp pq qp•Associative laws: (pq)r p(qr)
(pq)r p(qr)•Distributive laws: p(qr) (pq)(pr)
p(qr) (pq)(pr)•Identity laws: pT p pC p•Domination laws:(Universal bound laws) pT T pC C•Idempotent laws: pp p pp p•Negation laws: pp T pp C•Double negative laws: (p) p•De Morgan’s laws: (pq) pq
(pq) pq•Absorption laws: p(pq) p p(pq) p
Example
Is the following assertion a proposition?
This statement is false.
No, since this statement is neither “true” nor “false”.
Example
The nth statement in a list of 100 statements is
What conclusion can you draw from these statements?
Exactly n statements are false.
At most one statement can be true, then 99 statements are false.That is only the 99th statement is true.
Exactly n statements are false.
Example
The nth statement in a list of 100 statements is
What conclusion can you draw from these statements?
At least n statements are false.
50 first statements are true.The others are false.
Exactly n statements are false.
Example
The nth statement in a list of 100 statements is
What conclusion can you draw from these statements?
At least n statements are false.
99
CONTRADICTION
Conditional statement
ConverseThe converse of p q is q
p.
InverseThe inverse of p q is p
q.
Only if p only if q means If q then p.
p q
Valid arguments
An argument is valid means that if all hypotheses are true, the conclusion is also true.
Definition
An argument is a sequence of statements. All statements excluded the final one are called “hypotheses”, the final statement is called “conclusion”. A argument is the form:p ; q ; r ; … f (read therefore)
ExampleGiven an argument p (q r) ; r ; p qp q r qr p (q r) r p q
T T T T T F T
T T F T T T T
T F T T T F T
T F F F T T T
F T T T T F T
F T F T T T T
F F T T T F F
F F F F F T F
TRUE
VALIDValid arguments
( p1 p2 p3 … pn) q
Rules of inference Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
P
P Q
Rules of inference
P Q
P
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Rules of inference
PQ
P Q
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Rules of inference
P QP
Q
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Rules of inference
P Q Q
P
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Rules of inference
P QQ R
P R
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Rules of inference
P Q P
Q
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Rules of inference
P Q P R
Q R
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Rules of inference
P QP RQ R
R
Disjunctive addition Conjunctive
simplification Conjunction addition Modus ponens Modus tollens Hypothetical syllogism Disjunctive syllogism Resolution Dilemma
Example
Given two logical operators,p | q means ( p q )p q means ( p q )
Find a simple proposition for ( p q ) ( p q ).
( p q )
Example
Given two logical operators,p | q means ( p q )p q means ( p q )
Find a simple proposition for ( p q ) ( p q ).Find a proposition equivalent to pq using only .
(( p p ) q ) (( p p ) q )
Problem
Consider the following statements:
All students go to school.John is a student.Diana is a student.……
Of course we can conclude thatJohn goes to school.Diana goes to school.……
Predicate logic
The statement “All students go to school” has two parts:Variable students (denoted by variable x)“go to school” (the predicate)
This statement can be denoted by P(x), where P denotes the predicate “go to school”.P(x) is said to be the value of the propositional function P at x.Once a value has been assigned to the variable x, the statement P(x) becomes a proposition and has a truth value.
Quantifiers Universal quantification Existential quantification Unique existential quantification !
Consider a statement x P(x) Q(x).
ContrapositionIts contrapositive is x Q(x) P(x).
InverseIts inverse is x P(x) Q(x)..
ConverseIts converse is x Q(x) P(x).
Consider a statement x P(x) Q(x).
For a particular e,
P(e) is true,
therefore Q(e) is true.
Universal Modus Ponens
Consider a statement x P(x) Q(x).
For a particular e,
Q(e) is true,
therefore P(e) is true.
Universal Modus Tollens
Universal instantiationxP(x) P(c) if c U.
Universal generalizationP(c) for an arbitrary c U xP(x)
Existential instantiationxP(x) P(c) for some element c U
Existential generalization P(c) for some element c U xP(x)
Rules of inferences
The order of quantifiers
Given a predicate P(x,y): x + y = 0
x y P(x,y)y x P(x,y)
Nested quantifiers
x P(x) y Q(y) x y ( P(x) Q(y) ) y x ( P(x) Q(y) )
x P(x) x Q(x) x y ( P(x) Q(y) )
Prenex normal form (PNF)
Express the following theorem using the first order predicate logic.
Example
Mathematical induction
Set
George Cantor (1845-1918)
Set
Definition
A set is an unordered collection of objects.The objects are called the elements or
members of the set.The number of distinct elements in a set is
the cardinality of the set.
The Cartesian product of A and B, denoted by AB, is described by
{ (a,b) | a A b B }.
Defining sets L
1={ n| for n =1 2 3 … }
L2={ n | for n =1 3 5 7 … }
L3={ n | for n =1 4 9 16 … }
L4={ n | for n = 3 4 8 22 … }.
Membership problem
Machine model
Minput
output{ yes, no }
{ space of input }
{ space of yes-input }MEMBERSHIP DECISION
ExampleLet U be the universe described by
U = { x | 1000 x 9999}.Let Ai be the set of all numbers in U
such that the ith position is i.
Find the cardinality ofthe union of A1 A2 A3 and A4 ?
ExampleLet S be the set of all x that x does not
contain x.
S = { x | x x }Note that x is also a set.
Does S contain S ?Russell’s paradox Bertrand Russell (1872-1970)
Set
Operators
Union Mutually disjoint
Intersection PartitionDifferentDisjointComplementPower set
Set
Theorem Given sets A,B and C.
•Commutative laws: AB = BA AB = BA
•Associative laws: (AB)C = A(BC)
•Distributive laws: A(BC) = (AB)(AC)
•Idempotent laws: AU = A AU = U
•De Morgan’s laws: (AB)c = Ac Bc (AB)c = Ac Bc
•Alternative representation for set differenceA-B = ABc
•Absorption laws: A(AB) = A (AB)A = A
ExampleThe symmetric difference of A and B, ( A B ), is the set containing those elements in either A or B, but not in both A and B.
( A ( B C ) )= ( ( A B ) C )?YES
ExampleThe symmetric difference of A and B, ( A B ), is the set containing those elements in either A or B, but not in both A and B.
( A ( B C ) )= ( ( A B ) C )?YES
Given A C = B C
Must it be the case that A = B ?
Multisets
Definition
Multisets are unordered collections of elements where an element can occur as a member more than once.
{ m1.a1, m2.a2, m3.a3, …, mr.ar }
mi are called the multiplicities of the elements ai.OPERATORS: UNION, INTERSECTION, DIFFERENCE, SUM
Multisets
Definition
Multisets are unordered collections of elements where an element can occur as a member more than once.
{ m1.a1, m2.a2, m3.a3, …, mr.ar }
mi are called the multiplicities of the elements ai.OPERATORS: UNION, INTERSECTION, DIFFERENCE, SUM
Fuzzy sets
0 mi 1
Degree of membership
Relations & functions
Binary relationDefinitionLet A,B be sets. A binary relation R from A to B
is a subset of the Cartesian product AB. Given (x,y), ordered pair, in A B,
x is related to y by R, written xRy, iff (x,y)R.
Example (the congruence modulo 2 relation)
The relation R from Z to Z is defined as follows;
for all (x,y) ZZ, xRy iff x-y is even.
Example, 6R2, 120R36 etc.
Function
DefinitionA function F from A to B is a relation from A to B, F :
AB,that satisfies the following properties:
For every xA, there exists yB such that (x,y)F.For all xA, and y, zB, if (x,y)F and (x,z)F then
y=z.
For (x,y) F , we usually write y =F (x) = image of x under F, and x is called pre-image of y under F.
A is called domain of F.B is called co-domain of F.The set of all images of F is called range of F.
Compositions of functions
DefinitionA function f, g from A to B is a function from A to
B.
(f + g)(x) = f(x) + g(x).(f g)(x) = f(x) g(x)
The composition of the functions f and g, denoted by f g, is defined as
(f g)(x) = f (g ( x ) )
Function
Arrow diagramA function F from A to B.
1234
abcde
F(1) = bF(2) = aF(3) = bF(4) = e
A B
Injective function
DefinitionA function F from A to B is injective (or
one-to-one)
iff for all elements x and y in A,
if F(x] =F(y] then x = y.Or, equivalently,
if x y then F(x] F(y].
1234
abcde
A B
This function is not One-to-one.
Injective function
DefinitionA function F from A to B is injective (or
one-to-one)
iff for all elements x and y in A,
if F(x] =F(y] then x = y.Or, equivalently,
if x y then F(x] F(y].This function is an One-to-one.
1234
abcde
A B
DefinitionA function F from A to B is surjective (or
onto)
iff for any element y in B,it is possible to find an element x in Asuch that
y = F(x] .
1234
ab e
A B
This function is Onto.
Surjective function
DefinitionA one-to-one correspondence (or bijection)
F from A to B is a function that is both one-
to-one and onto.1234
abcde
A BThis function is not a
bijection.
Bijective function
DefinitionA one-to-one correspondence (or bijection)
F from A to B is a function that is both one-
to-one and onto.1234
abcde
A B
Bijective function
This function is not a bijection.
DefinitionA one-to-one correspondence (or bijection)
F from A to B is a function that is both one-
to-one and onto.1234
abcd
A B
Bijective function
This function is a bijection.
Properties
DefinitionLet R be a binary relation on A.R is reflexive iff for all xA, x R x .R is symmetric iff for all x,yA,
if x R y then y R x.R is transitive iff for all x,y,zA,
if x R y and y R z then x R z.
Equivalence relation
DefinitionR is a equivalence relation on A iff
R is a binary relation on A. R is reflexive.R is symmetric.R is transitive.
Transitive closure
DefinitionLet R be a binary relation on A.The transitive closure of R is the binary
relation Rt on AThat satisfies the following three
properties:Rt is transitive.R Rt.S is any other transitive that
contains R then Rt S.
Mutually disjoint
DefinitionSets A1,A2, A3, …,An are Mutually
disjoint(pairwise or nonoverlapping)
Iff, any two sets Ai,Aj with distinct subscripts have not any elements in common, precisely AiAj= empty set .
Set partition
DefinitionA collection of nonempty sets
{A1,A2, A3, …,An}
is a Partition of a set A Iff, A = A1A2 A3 … An andA1,A2, A3, …,An are mutually
disjoint.
DefinitionGiven a partition of A={A1,A2, A3, …,An}.
The binary relation induced by the partition, R,
is defined on A as follows:for all x,y A, x R y Iff,
there is a subset Aj of the partition such that both x and y are in Aj.
Set partition
TheoremLet A be a set with a partition andLet R be the relation induced by
the partition.Then R is reflexive, symmetric
and transitive.
Set partition
How to prove this
theorem?
Equivalence class
DefinitionSuppose A is a set and R is a equivalence relation on A.For each a A, the equivalence class of a, denoted [ a ],is the set of all elements x in A such thatx is related to a by R.
[ a ] = { x A | x R a }.
TheoremLemma 1Let R be an equivalence relation on A, a b
A.
If a R b then [ a ] = [ b ].Lemma 2Let R be an equivalence relation on A, a b
A, then
either [ a ] [ b ] = or
[ a ] = [ b ].
TheoremIf A is a nonempty set and R is an equivalence
relation on A,
then the distinct equivalence classes of R form a partition of A; that is, the union of the equivalence classes is all of A and the intersection of any two distinct classes is empty.
Antisymmetric
DefinitionA relation R on a set A such that
(a,b) and (b,a) are in R only if a=b, for all a,b in A, is called antisymmetric.
Example
Let R be a relation on the set AR = { (a,b) | a < b }
Find the inverse relation R-1 andthe complementary relation R.