MIT 6.042 mathematics for computer science

 

20:08 2013-11-20 Wednesday

start mathematics for computer science,
lec1, induction & proofs!
20:10 2013-11-20
What is a proof?
a proof is a method for acertaining
the truth!
20:12 2013-11-20
truth, falsehood
20:13 2013-11-20
How to ascertaining truth?
experimentation & observation
sampling & counta example
20:14 2013-11-20
judge & jury establish the truth
20:18 2013-11-20
conviction:
which is good, because it transfer the
burden of argument to someone disbelief!
20:20 2013-11-20
What is a mathematical proof?
a mathematical proof is a verification of
a proposition by a chain of logic deduction
from a set of axioms!
20:21 2013-11-20
What is a proposition?
a proposition is a statement that is either
true or false!
20:22 2013-11-20
2 + 3 == 5 is a true proposition!
20:23 2013-11-20
here the upside down A is the "for all" symbol!
20:24 2013-11-20
What is a predicate?
a predicate is a proposition whose truth
depends on the value of a variable!
20:32 2013-11-20
this proposition is conjectured by Euler
to be true in ....
20:34 2013-11-20
positive natrual numbers
20:36 2013-11-20
factors is about how to break cryptic
system like RSA!
20:38 2013-11-20
4 color theorem is finally proved
in 1977 by using computers!
20:41 2013-11-20
lemma?
20:42 2013-11-20
conjecture?
20:47 2013-11-20
implies
20:48 2013-11-20
let me define what imply means?
20:48 2013-11-20
What is an implication?
an implication p => q is said to be true
if p is false or q is true!
20:51 2013-11-20
if pig can fly, I will be king!
20:52 2013-11-20
pig fly => I'm king,
this proposition is true, because
pig fly is false,
20:53 2013-11-20
iff == if & only if
20:54 2013-11-20
false imply everything!
20:58 2013-11-20
What are axioms?
axioms are just propositions that we
assumed to be true!
21:00 2013-11-20
axiom means "think worthy"!
21:01 2013-11-20
axioms can be contradictory in
different context!
21:03 2013-11-20
hyperbolic geometry
21:04 2013-11-20
there seems to be two guiding
principles for axioms!
21:05 2013-11-20
axioms should be
1. consistent
2. complete
21:05 2013-11-20
What does it mean by saying axioms
are consistent?
a set of axioms is consistent if
no proposition can be proved to be
both true & false!
21:10 2013-11-20
there does not exists a set of axioms
that are both consistent & complete!
21:10 2013-11-20
there is no holy grail!
/
9:08 2013-11-21 Thursday
start mathematics for computer science, lec 2
9:09 2013-11-21
direct proof, indirect proof
9:09 2013-11-21
logical induction, axioms, proposition!
9:09 2013-11-21
proof by contradiction
9:18 2013-11-21
hypothesis
9:18 2013-11-21
What is a "proof by contradiction"?
to prove P is true, we assume P is false /
(NOT P is true), then use that hypothesis to derive
a falsehood or contradiction!
9:21 2013-11-21
let's prove that square root of 2 is
irrational
9:21 2013-11-21
What is a rational number?
a rational number is a number which can
be represented as ratio of "numerator / denominator"
9:22 2013-11-21
I'm going to assume for the purpose of
contradiction that NOT P is true(P is fale),
9:23 2013-11-21
Why proof by contradiction works?
because if NOT P => F is true,
then either F is true is true, or NOT P is false!
because F is true cannot be true, then
NOT P is false must be true!
9:25 2013-11-21
fraction in lowest terms, that means a & b
have no common divisors!
9:25 2013-11-21
common divisor
9:25 2013-11-21
GCD == Greastest Common Divisor
9:27 2013-11-21
4 | a * a // four divides a squared
9:29 2013-11-21
# // you got a contradiction
9:30 2013-11-21
□ // check or QED
9:33 2013-11-21
they like rational numbers like 1 / 7,
because 1 / 7 == .142857 repreating
9:33 2013-11-21
rational numbers is finite in the sense
that you always find the repeating pattern!
9:35 2013-11-21
the axioms they use is not consistent,
every theorem they prove now is suspectible!
9:50 2013-11-21
induction is by far the most powerful and
commonly used technique in computer science!
9:51 2013-11-21
proof by induction
9:52 2013-11-21
induction is really just an axiom!
9:54 2013-11-21
p => q
// p implies q, either p is false, or q is true
// this is called implication!
9:56 2013-11-21
logical deduction
9:56 2013-11-21
deduction
induction
9:57 2013-11-21
each domino knocks over the nexts
10:03 2013-11-21
this notation is very ambiguous!
10:07 2013-11-21
What's your predicate? What is your
inductive hypothesis?
10:09 2013-11-21
BaseCase + inductive hypothesis
10:13 2013-11-21
How can I show an implication is true?
10:13 2013-11-21
P(n) => P(n+1) // implication
this means either P(n) is false, or P(n+1) is true
10:14 2013-11-21
assume P(n) is true for purpose of induction
10:18 2013-11-21
How can we know that P(n) => P(n+1)?
we need to show tha either P(n) is false,
or P(n+1) is true
if P(n) is false, we're done!
else we need to show that P(n+1) is true!
10:35 2013-11-21
induction don't always have to start at zero!
10:36 2013-11-21
How to prove "All horses are the same color"?
predicate P(n):
in any set of n >= 1 horses,
the horses all have the same color
10:52 2013-11-21
assume P(n) is true, that is all n horses are
the same color, consider a set of n+1 horses,
H1, H2, H3, ..., Hn+1
10:53 2013-11-21
you can pick any set of n horses from these,
they must be the same color, but how can you
prove that all n+1 horses are the same color?
10:57 2013-11-21
What's the flaw here?
11:19 2013-11-21
use L-shaped tile in the courtyard
11:19 2013-11-21
tile this courtyard perfectly using
these L-shaped tiles!
11:20 2013-11-21
leaving one square in the center for the
stature!
11:23 2013-11-21
induction hypothesis
BaseCase + InductionStep
11:26 2013-11-21
assume P(n) to verify I.H.
11:26 2013-11-21
I.H. == Inductive Hypothesis
11:35 2013-11-21
with a corner missing
11:44 2013-11-21
make the induction hypothesis be
much stronger!
11:49 2013-11-21
pick a good one(induction hypothesis),
life is easy, pick a bad one, life is
hard!
---------------------------------------------
//
16:25 2013-11-22 Friday
programming abstractions in c++ reading
done!
16:59 2013-11-22
start discrete mathematics for CS, lec 2,
strong induction
17:01 2013-11-22
using lemmas the same way you use subroutines!
17:04 2013-11-22
race condition
17:07 2013-11-22
rock, solid proof
17:08 2013-11-22
fundamental theorem of algebra
17:10 2013-11-22
conjecture????
17:15 2013-11-22
Fermat's Last Thm
17:26 2013-11-22
invariant is a very powerful & commonly
used concept in computer science!
17:28 2013-11-22
all state reachable by legal move has
to have this invariant, and this special
state does not have this invariant, so
it's not reachable!
17:29 2013-11-22
invariant
17:29 2013-11-22
the initial state
A B C
D E F
H G
to prove it's not possible to reach
the orderly state using legal move!
17:31 2013-11-22
What's that property, the invariant
property?
17:32 2013-11-22
row move,
17:33 2013-11-22
let's state that as a lemma
17:33 2013-11-22
lemma 1: a row move does not change
the order of the items
17:37 2013-11-22
relative order does not change in
this case
17:38 2013-11-22
column move in more interesting
17:38 2013-11-22
find the invariant!
17:42 2013-11-22
lemma 2:
column move changes the relative
order of precisely 2 pair of items
17:46 2013-11-22
it changes relative order with 2
other items
17:47 2013-11-22
let's really specify that now!
17:49 2013-11-22
What is an inverted pair?
inverted pair: if L1 precedes L2 alpabetically,
but L1 is after L2 in puzzle!
17:50 2013-11-22
in the original configureation, there
is just 1 inverted pair!
17:54 2013-11-22
in the final configuration, there is
zero inverted pair!
17:56 2013-11-22
lemma 3: during the move, the number of inversions
can only increase by 2, or decrease by 2,
or stay the same
17:56 2013-11-22
in row move, the inversion number does not
change
17:59 2013-11-22
during the move, the parity of inversions
stay the same!
18:00 2013-11-22
parity means even or odd!
18:04 2013-11-22
we finally found the invariant of this
problem:
the parity of number of inversions is odd!
18:06 2013-11-22
proof by induction
18:06 2013-11-22
inductive hypothesis P(n):
after any sequence of moves from the start
state, the parity of number of inversions
is odd!
18:08 2013-11-22
BaseCase + InductiveStep => inductive hypothesis
18:09 2013-11-22
for any n >= 0, we need to show that P(n) => P(n+1)
is true!
18:09 2013-11-22
P(n) => P(n+1) // P of n implies P of n+1
either P(n) is false, or P(n+1) is true!
18:22 2013-11-22
move is a transition between state!
18:24 2013-11-22
invariance!
18:25 2013-11-22
strong induction
18:25 2013-11-22
regular induction
18:25 2013-11-22
strong induction axioms
18:27 2013-11-22
the only difference between ordinary induction
& strong induction is that:
in regular induction, you just show P(n) => P(n+1),
in strong induction, you need to show that
P(0) & P(1) & ... & P(n) => P(n+1)!
18:29 2013-11-22
in strong induction, you need to assume more:
you assume P(0) & P(1) & ... & P(n) all true!
18:32 2013-11-22
anything you can prove with strong induction,
you also can prove using regular induction,
it's just much difficult!
18:33 2013-11-22
you're going to assume all these are true
at the inductive step!
18:33 2013-11-22
we got a stack of 8 blocks here!
18:34 2013-11-22
now divide this stack into 2 substacks!
18:34 2013-11-22
unstacking game
18:35 2013-11-22
the goal is get the most number of points
18:36 2013-11-22
TA == Teaching Assistant
18:39 2013-11-22
that's a pretty pathetic first move!
18:42 2013-11-22
there is not much options left for your guys!
18:43 2013-11-22
we got a tie!
18:47 2013-11-22
Theorem: All strategies for the n-block game
produce the same score
18:48 2013-11-22
proof by strong induction
18:48 2013-11-22
proof by induction
18:49 2013-11-22
I.H. == Inductive Hypothesis
18:49 2013-11-22
I think you already got on a good track here
18:51 2013-11-22
InductiveStep: assume P(1), P(2), ..., P(n) to
prove P(n+1)!
18:52 2013-11-22
let's figure out our score for that scenario
18:53 2013-11-22
with n+1 blocks, we split into k, n+1-k,
P(n+1) = k(N+1-k) + P(k) + P(n+1-k)
18:54 2013-11-22
we already know P(1) == 0 // BaseCase
18:55 2013-11-22
makes much easier using strong induction
18:56 2013-11-22
make it stronger!
18:56 2013-11-22
make a strong induction hypothesis!
18:58 2013-11-22
let's check it out!
18:59 2013-11-22
first assume S(n) = n * (n-1) / 2
for 0 ~ n
-----------------------------------------
///
16:58 2013-11-23 Saturday
do nothing....

10:25 2013-11-26 Tuesday
start discrete mathematics for computer science,
lec 4, number theory
10:26 2013-11-26
What is a number theory?
it's about study of the integers
10:28 2013-11-26
number theory used in the field of cryptography
only 40 years ago!
10:29 2013-11-26
cryptograph is about hiding numbers
10:35 2013-11-26
hey, you focus on the problems at hand?
10:39 2013-11-26
m | a // m divides a
10:40 2013-11-26
for example: 3 | 6
10:41 2013-11-26
our tools: state, state machine(SM)
10:42 2013-11-26
3 basic thing we can do:
pouring, empting, refilling
10:43 2013-11-26
the state machine we're going to use
here look like this...
10:44 2013-11-26
What is our states?
the state: pairs (x, y)
// x: gallons in a-jug
// y: gallons in b-jug
10:46 2013-11-26
start-state: (0, 0)
10:46 2013-11-26
state transition
10:50 2013-11-26
pouring one of the jug to another
filling, empting...
10:51 2013-11-26
(x, y) -> (0, x+y)
// only happens if jug-b has sufficient space
// that is x + y <= b!
11:03 2013-11-26
the other possibility of pouring?
if x + y > b, then
(x, y) -> (x-(b-y), b) // jug-b is now full!
11:20 2013-11-26
they're now fully described by the state machine!
11:22 2013-11-26
What we have did is fully described by this
state machine!
11:25 2013-11-26
What is the invariant in this problem?
assume m | a, m | b
Invariant: P(n) == "If (x, y) is the state
after n transitions, you still have
m | a, m | b
11:30 2013-11-26
proof by induction:
BaseCase + InductiveStep
11:44 2013-11-26
What can invariant do for us?
if a == 44, b == 55, is it possible
that we get 4 gallons at last?
NO! because m == 11, m | a, m | b
but !(m | 4)
11:48 2013-11-26
common divisor
11:48 2013-11-26
GCD == Greatest Common Divisor
11:49 2013-11-26
if GCD(a, b) == 1, then we said a & b
are relatively prime to each other!
11:54 2013-11-26
Theorem: Any linear combination L = s * a + t * b
of a & b with 0 <= L <= b can be reached!
12:15 2013-11-26
but how to prove this theorem?
12:19 2013-11-26
for example in order to get 4 gallons,
we have jug-a == 3, jug-b == 5,
then 4 == -2 * 3 + 2 * 5
12:55 2013-11-26
q == quotient,
r == remainder
13:07 2013-11-26
lemma: gcd(a, b) == gcd(rem(b,a), a)
13:12 2013-11-26
divisibility
13:15 2013-11-26
gcd(a, b) is actually a linear combination
of a & b!
13:16 2013-11-26
Euclid's algorithm
13:24 2013-11-26
in every step, the remainder is getting smaller
& smaller!
13:26 2013-11-26
theorem:
the GCD(a, b) is actually the linear combination
of a & b!
13:30 2013-11-26
Theorem:
GCD(a, b) is the smallest positive linear
combination of a & b!
-----------------------------------------------
14:37 2013-11-26
start review mathematics for computer science,
lec 4, number theory I
14:37 2013-11-26
divisibility
14:45 2013-11-26
What is a number theory?
number theory is actually the study
of the integers!
14:46 2013-11-26
What is cryptography?
cryptography is the study & practice
of hiding numbers
14:58 2013-11-26
obvious if you have jug-a == 3 gallon
&& jug-b == 6 gallon, you'll never get
precise 4 gallons!
15:02 2013-11-26
Theorem: if m | a && m | b, then m | any
result you can get with pouring, filling, empting!
15:03 2013-11-26
the state machine we're going to use here
look like this!
15:05 2013-11-26
we'll denote the state using pairs (x, y)!
15:06 2013-11-26
this is our start-state: (0, 0)
15:07 2013-11-26
state transition
15:08 2013-11-26
the pouring of one jug into another is
actually more complex!
15:10 2013-11-26
this can only happen if there is
sufficient space!
(x, y) -> (0, x+y) // x + y <= b
15:15 2013-11-26
we completely fill this up to its capacity!
15:17 2013-11-26
now it's fully described by this state machine!
15:23 2013-11-26
proof by induction: assume m | a, m | b
the Invariant P(n): after n state transitions,
m | x, m | y
15:26 2013-11-26
proof by induction
15:26 2013-11-26
to prove this invariant P(n) using
proof by induction!
15:26 2013-11-26
BaseCase + InductiveStep
15:27 2013-11-26
suppose that (x, y) is the state after
n transitions!
the inductive hypothesis is that
(m | x) && (m | y)
15:28 2013-11-26
What happens after another transition?
15:29 2013-11-26
now you know why from 2 jugs with 4 gallons
& 6 gallons can not reach a 3 gallon?
because it violet the invariant
m == 2, m | a && m | b,
but m | 3 are not true!
15:36 2013-11-26
first we assume that (m | a) && (m | b)!
15:39 2013-11-26
just find the Invariant!
15:40 2013-11-26
this is just the standard technique that
we use in all these class!
15:42 2013-11-26
if jug-a == 33, jug-b == 55, how can we
get 4 gallons?
it's impossible because the invariant!
m == 11, m | a && m | b,
the invariant P(n) says that after n
state transitions, m | x && m | y!
15:44 2013-11-26
but clearly m | 4 is false, the invariant
is violated!
15:45 2013-11-26
so all of this stuff helps to define
a new concept as well!
15:46 2013-11-26
GCD == Greatest Common Divisor
15:46 2013-11-26
common divisor
15:48 2013-11-26
if the GCD of 2 numbers is 1, then we
call these two numbers relative prime
to each other, or coprime!
15:55 2013-11-26
Theorem: any linear combination L == s * a + t * b
of a & b with 0 <= L <= b can be reached
15:59 2013-11-26
for example: 4 can be represented as a linear
combination of 3 & 5 as 4 = (-2) * 3 + 2 * 5!
16:05 2013-11-26
let's figure out how this works!
16:06 2013-11-26
notice that we can rewrite L as:
L = sa + tb = (s + mb)a + (t-ma)b
16:07 2013-11-26
let s' = s + mb, the we can write L as
L = s'a + t'b with s' > 0
16:09 2013-11-26
alright, so what's the algorithm is going
to do for us!
16:10 2013-11-26
the algorithm is about repeatedly fill &
pour out jugs in a very special way!
16:10 2013-11-26
so how does this algorithm work?
16:12 2013-11-26
the theorem says that if L is a linear combination
fo a & b, then what's the algorithm that can obtain
L gallons?
1. Fill the a-jug
2. Pour into the b-jug
when the b-jug becomes full, empty it out
and continue pouring until a-jug is empty
16:16 2013-11-26
so let's take an example to see how this works!
16:18 2013-11-26
essentially in order to get 4 gallons....
16:19 2013-11-26
4 = (-2) * 3 + 2 * 5! can be rewritten as
4 = 3 * 3 -1 * 5
// now we get positive coefficient for 3(a-jug)
16:20 2013-11-26
that is just saying we need to fill the
a-jug 3 times in order to get a 4 gallons!
16:22 2013-11-26
What are the 3 steps in order to get a 4 gallons
using 4 = 3 * 3 -1 * 5 ?
16:24 2013-11-26
so let's think about this a little
bit to see how to formalize this?
16:27 2013-11-26
L = s'a + t'b with s' > 0
we can see this as fill a-jug s' times,
empting b-jug t' times, then the remainder
is what we want!
16:28 2013-11-26
this is just s' * a == b * q + r
with q == quotient, r == remainder
16:43 2013-11-26
the GCD(3, 5) == 1, we note that
1 can be written as a linear combination
of 3 & 5 as
1 = 2 * 3 - 1 * 5
16:51 2013-11-26
Why you can say that GCD(a, b) is a linear
combination of a & b?
16:52 2013-11-26
lemma: gcd(a, b) == gcd(rem(b, a), a)
// rem == remainder
16:54 2013-11-26
so what are we going to use here?
16:55 2013-11-26
do the trick once more!
16:59 2013-11-26
Euclid's Algorithm
17:01 2013-11-26
OK, how do we do to proof?
17:07 2013-11-26
divisibility
17:08 2013-11-26
so this is essentially what I'm using
here repeatedly!
17:11 2013-11-26
now we can finally proove this beautiful
theorem!
17:13 2013-11-26
the invariance that we're going to use
is that....
17:19 2013-11-26
What is the invariance P(n)?
you want of find GCD(a, b) using Euclid's
Algorithm, after n steps you reach (x, y),
the GCD(a, b) == GCD(x, y)!
17:21 2013-11-26
prove the invariance using "proof by induction"!
17:21 2013-11-26
inductive step: assume P(n), to prove P(n+1)!
17:22 2013-11-26
notice rem(y, x) == y - q * x!
// rem == remainder, q == quotient
17:24 2013-11-26
in every step the remainder is getting
smaller & smaller!
17:25 2013-11-26
now we'll combine all 3 theorems in 1 goal!
17:27 2013-11-26
Theorem: GCD(a, b) is actually the smallest
positive linear combination of a & b!
17:28 2013-11-26
so we can combine those 3 to get a theorem!
------------------------------------------------
17:41 2013-11-26
start mathematics for computer science,
lec 4, number theory II, encryption
17:43 2013-11-26
What is encryption?
in order to avoid some in the middle to
intercept your message, by using some
encryption algorithm E
17:45 2013-11-26
beforehand: "keys" are exchanged!
17:47 2013-11-26
encrypted message / plain message
17:48 2013-11-26
encryption / decryption
17:49 2013-11-26
using number theory in cryptography!
17:49 2013-11-26
Turing' code V1
17:50 2013-11-26
we want to use some tricks with number
in order to encrypt it!
17:52 2013-11-26
the prime numbers are distributed densely
inside the integers
17:53 2013-11-26
an encryption scheme
17:54 2013-11-26
in the Turing's code V1:
beforehand: exchange secret prime K
the encryption algorithm: m' = m * K
// m' is the encrypted message
// m is the plain message
17:56 2013-11-26
how do we decrypt it?
this seems just straight forward,
m = m' / K
17:57 2013-11-26
hard to factor a product of 2 large primes!
18:00 2013-11-26
How to crack this Turing's code V1?
m1' = m1 * k
m2' = m2 * k
assume that m1, m2, k are all prime numbers,
if the bad guy intercept the encrypted message
m1 & m2, then find the GCD(m1, m2) == k, the
the cryption is cracked!
18:02 2013-11-26
modular arithmetic
18:02 2013-11-26
Turing's code V2
18:03 2013-11-26
we'll do something much more complicated
than just multiplying prime numbers!
18:05 2013-11-26
What is the schem used in the Turing's code V2?
beforehand: exchange public prime P & secret prime K
18:06 2013-11-26
then how to encrypt?
message as a number m ∈{0, 1, 2..., P - 1}
compute m = rem(m * k, P)
18:11 2013-11-26
now we can get into modular arithmetic
18:11 2013-11-26
multiplicative inverse
18:12 2013-11-26
a & b are relatively prime iff GCD(a, b) == 1
18:13 2013-11-26
What does GCD(a, b) == 1 means?
this implies that the smallest positive linear
combination of a & b is 1!
18:14 2013-11-26
this just implies that there exist s & a
such that s * a + t * b == 1
18:17 2013-11-26
What does it mean by saying
x is congruent to y modulo n: x ≡ y(mod n)?
for example 31 ≡ 16(mod 5)
18:20 2013-11-26
x ≡ y(mod n) iff n | (x - y)
18:27 2013-11-26
What is a multiplicative inverse?
for example if 2 * 3 ≡ 1(mod 5), then
we can say that 2 is 3's multiplicative
inverse modular 5!
18:33 2013-11-26
now we can start talking about the 2nd
version of the Turing code?
18:35 2013-11-26
rem(mk, p) ≡ mk (mod p)
// rem(mk, p) is congruent to mk modulo p
18:37 2013-11-26
because
m' = rem(mk, p), rem(mk, p) ≡ mk (mod p), get
m' ≡ mk (mod p)
// m' is the encrypted message,
// m is the plain message
18:42 2013-11-26
we simply use the multiplicative inverse
of k
18:47 2013-11-26
can we attack this scheme?
18:50 2013-11-26
known plaintext attack:
know plain message m & encrypted message
m' = rem(mk, p)
// rem == remainder, k private prime
// p public prime
18:53 2013-11-26
p is a public prime, m is also prime,
so GCD(m, p) == 1, then we computer the
multiplicative inverse of m such that
m * m^(-1) ≡ 1 (mod p)
// m * m^(-1) is congruent to 1 modulo p
//
18:58 2013-11-26
s.t. == such that
19:01 2013-11-26
compute k's multiplicative inverse modulo by p
19:04 2013-11-26
and it's widely used in practice!
19:06 2013-11-26
What's the multiplicative inverse of x modulo n?
it's a number x^(-1), in {0, 1, ..., n-1} such that
x * x^(-1) ≡ 1 (mod n)
// x^(-1) is the multiplicative inverse of x modulo n
19:12 2013-11-26
What's a Euler's totient function?
this function is denoted by Φ(n), it
denotes the number of integers in {1, 2, 3, ... n-1 }
that are relatively prime to n
19:14 2013-11-26
this is the fundamental quantity
19:16 2013-11-26
What does that mean by a & b are relative prime?
two integers are relatively prime iff
GCD(a, b) == 1
19:17 2013-11-26
What is Φ(12)?
int phi(int n) {
int n = 0;
for (int i = 0; i < 12; i++) {
if (GCD(12, i) == 1) ++n;
}
return n;
}
//
10:34 2013-11-27 Wednesday
mathematics for computer science, lec 5
Number theory II, encryption(RSA etc)
10:39 2013-11-27
cryptology in generaly is the art of
hiding information!
10:40 2013-11-27
beforehand: "keys" are exchanged between sender & receiver
10:43 2013-11-27
encryption scheme
10:43 2013-11-27
decryption
10:43 2013-11-27
plain message, encrypted message
10:43 2013-11-27
keys
10:44 2013-11-27
Turing's code V1
10:47 2013-11-27
the prime numbers are distributed densely
inside the integers
10:49 2013-11-27
beforehand: exhange private prime k
encryption: m' = mk // k is the private prime
10:50 2013-11-27
decryption: m = m'/k
m is the plain message
m' is the encrypted message
10:51 2013-11-27
hard to factor a product of 2 large primes
RSA encryption scheme which is widely used,
also use this fact!
10:52 2013-11-27
How to crack Turing's code V1?
it's relatively easy to crack Turing's code V1,
just notice that m1' = m1 * k, m2' = m2 * k
we can find the GCD(m1', m2') == k, then the
encryption scheme is cracked!
// we got the private prime k!
10:54 2013-11-27
modular arithmetic
10:54 2013-11-27
Turing's code V2
beforehand: exchange a public prime p &
a secret prime k
10:56 2013-11-27
How the encryption process works in
Turing's code V2?
message as a integer in {0, 1, 2, ..., p-1 }
compute m' = rem(mk, p)
// m' is the encrypted message,
// m is the plain message
// k is the private prime
// p is the public prime
// rem == remainder
10:59 2013-11-27
multiplicative inverse
11:01 2013-11-27
What does it mean by saying that a & b
are relatively prime?
a & b are relatively prime iff GCD(a, b) == 1
11:10 2013-11-27
so this is a property that we'll be using
11:14 2013-11-27
What is a congruence?
x is congruent ot y modulo n : x ≡ y(mod n)
iff n | (x - y)
11:16 2013-11-27
iff == if & only if
11:17 2013-11-27
an example for congruence:
31 ≡16(mod 5) because 5 | (31 - 16)
11:19 2013-11-27
we're going to use this framework!
11:19 2013-11-27
What is a multiplicative inverse?
11:21 2013-11-27
What is the multiplicative inverse of x mod n?
the multiplicative inverse of x mod n is a number
inv(x), in {0, 1, 2, ... n-1}
s.t. x * inv(x) ≡ 1 (mod n)
11:23 2013-11-27
s.t. == such that
11:25 2013-11-27
Ex. 2 * 3 ≡ 1 (mod 5)
because 5 | (2 * 3 - 1)
so what does this mean?
2 ≡ inv(3) (mod 5)
// inv(3) is multiplicative inverse of 3
11:29 2013-11-27
5 * 5 ≡ 1 (mod 6)
now we see something funny happening!
5 ≡ inv(5) (mod 6)
11:32 2013-11-27
using the concept of congruence, we can see
rem(mk, p) ≡ mk (mod p)
// because p | (mk - rem(mk, p))
11:34 2013-11-27
because we know
m' = rem(mk, p) // encrypted message
11:35 2013-11-27
we got m' ≡ mk (mod p)
11:37 2013-11-27
if we have a multiplicative inverse of
k mod p, that is
k * inv(k) ≡ 1 (mod p)
11:39 2013-11-27
we got m' * inv(k) ≡ mk * inv(k) ≡ m (mod p)!
11:39 2013-11-27
then let's see how we can decrypt?
11:42 2013-11-27
because we know m(the plain message) is
in the range of {0, 1, 2, ... , n-1}, we can
rewrite m' * inv(k) ≡ m (mod p) as
m ≡ rem(m' * inv(k), p) // rem == remainder
11:44 2013-11-27
we also have p | (m' * inv(k) - m)
11:45 2013-11-27
this is the decryption:
m ≡ rem(m' * inv(k), p)
11:50 2013-11-27
What is the "known-plaintext attack"?
assume we know the plain message m &
encryption message m' = rem(mk, p)
11:52 2013-11-27
you can also write the encryption:
m' ≡ mk (mod p)
11:58 2013-11-27
because p is the public prime, so
GCD(m, p) == 1 // m & p are relatively prime
12:05 2013-11-27
because GCD(m, p) == 1, we can say that
there exists a linear combination of m & p
which is equal to 1!
12:05 2013-11-27
then we want to find the multiplicative inverse
of m modolo p?
m * inv(m) ≡ 1 (mod p)
12:09 2013-11-27
if I found the multiplicative inverse of m, that
is inv(m), then
m' * inv(m) ≡ km * inv(m) ≡ k (mod p)
12:11 2013-11-27
because I know m' & multiplicative inverse of m,
I know k (mod p)!
12:11 2013-11-27
if I know k, I can compute its multiplicative inverse!
12:12 2013-11-27
then I can decrypt any encrypted message
m ≡ rem(m' * inv(k), p)
12:15 2013-11-27
RSA is widely used in practice!
12:15 2013-11-27
Ruler's Totient Function denoted by Φ(n),
which denotes the number of integers in the
range {0, 1, 2, ...., n-1} which is relatively
prime to n!
12:24 2013-11-27
but now let's just talk about this as an
abstract notion!
12:25 2013-11-27
Euler's theorem
12:26 2013-11-27
What does the Euler's theorem says?
if GCD(n, k) == 1 => exp(k,Φ(n)) ≡ 1 (mod n)
12:31 2013-11-27
1st lemma:
if GCD(n, k) == 1, then assume
ak ≡ bk (mod n) => a ≡ b (mod n)
12:33 2013-11-27
you can use the multiplicative inverse
to proof the above lemma!
14:20 2013-11-27
GCD(n, k) == 1 iff k has a multiplicative inverse
???
14:20 2013-11-27
// GCD(n, k) is a linear combination of n & k
GCD(n, k) == 1 <=> exist s, t s.t. ns + kt == 1
<=> n | (kt - 1)
<=> kt ≡ 1 (mod n)
// kt is congruent to 1 modulo n
14:27 2013-11-27
we have essentially shown that if GCD(n, k) == 1,
then k has an multiplicative inverse t s.t
kt ≡ 1 (mod n)
14:33 2013-11-27
we can use the above conclusion to prove
the 1st lemma
14:36 2013-11-27
lemma 2:
suppose that GCD(n, k) == 1, K1, K2, ..., Kr
in {1, 2, 3, ... , n-1} denote the integers
relative prime to n
notice that r = Φ(n) // by Euler's Totient Theory
how to prove that
{rem(K1 * k, n), rem(K2 * k, n), ..., rem(Kr * k, n)}
== {K1, K2, ..., Kr}
14:42 2013-11-27
so we'll start with 1st part!
15:09 2013-11-27
Fermat's little theorem
15:14 2013-11-27
What does Fermat's little theorem say?
suppose p is prime & if you have k in the
range k = {1, 2, ..., p-1}, then we can
conclude that:
exp(k, p-1) ≡ 1 (mod n)
15:17 2013-11-27
because p is prime, then we have
1, 2, ..., p-1 are all relative prime to p!
15:18 2013-11-27
so by Euler's Totient Function: Φ(p) == p-1
15:23 2013-11-27
so we got
exp(k, Φ(p)) ≡ 1 (mod p)
=> exp(k, p-1) ≡ 1 (mod p)
15:25 2013-11-27
we can also use this theorem to compute
the multiplicative inverse of k!
15:26 2013-11-27
k * exp(k, p-2) == exp(k, p-1) == 1 (mod p)
15:28 2013-11-27
How does the RSA work?
beforehand: receiver creates public key &
secret key
15:29 2013-11-27
receiver will publish the public key while
keep the secret key!
15:29 2013-11-27
anyone want to send message will encrypt using
the public key, then the encrypted message will
be sent to the receiver, the receiver use the
secret key to decrypt the encrypted message!
15:31 2013-11-27
1st step: generate 2 distinct primes p & q!
2nd step: n = p * q
3rd step: select e s.t. GCD(e, (p-1)(q-1)) == 1
// the public key is going to be a pair (e, n)!
4th step: compute d st. d * e ≡ 1 (mod (p-1)(q-1))
// the secret key is going to be the pair (d, n)!
15:41 2013-11-27
the sender knows the public key (e, n), and use
this to encrypt the message, the receiver knows
the secret key (d, n), use this to decrypt the message!
15:42 2013-11-27
How to encrypt using RSA?
encryption: m' == rem(exp(m, e), n)
// m == plain message, m' == encrypted message
// (e, n) is the public key
15:44 2013-11-27
How to decrypt using RSA?
decryption: m == rem(exp(m', d), n)
15:53 2013-11-27
let's apply Fermat's theorem, and see how
we can use this?
15:59 2013-11-27
by the definition of congruency
16:02 2013-11-27
breaking the scheme reduce to solve
some really hard problem!
-----------------------------------------
16:24 2013-11-27
start mathematics for computer science,
lec 6: Graph theory & coloring
16:24 2013-11-27
graph theory altogether 2 * 3 == 6 videos!
16:25 2013-11-27
today we're going to talk about sex!
16:27 2013-11-27
on average, who has more opposite gender
partners, men or women?
16:29 2013-11-27
opposite gender partners
16:32 2013-11-27
this is our central claim
16:33 2013-11-27
this gives us the disparity of ...
16:37 2013-11-27
nodes, edges
16:38 2013-11-27
we give a formal definition of a graph
16:38 2013-11-27
Def: A graph G is a pair of set (V, E)
16:39 2013-11-27
V == Vertices(nodes)
E == Edges
16:40 2013-11-27
unordered pair of vertices
16:41 2013-11-27
directed edges
16:42 2013-11-27
but we don't require the graph has any
edges!
16:45 2013-11-27
What does it mean by saying 2 nodes are
adjacent?
two nodes are adjacent if they're connected
by an edge
16:46 2013-11-27
closely related is the definition of incident!
16:47 2013-11-27
What is incident?
Ex. if edge e is x1 <-> x2, then e is incident
to v1 & e is incident to v2!
16:48 2013-11-27
What is the degree of a node?
the number of edges incident to a node
is called the degree of a node!
16:49 2013-11-27
What is a simple graph?
a graph is simple if it has no loops or
multiple edges
16:50 2013-11-27
multiedge == multiple edges
16:51 2013-11-27
How are we going to use graph to model
the problem of opposite gender partners?
16:52 2013-11-27
edges: opposite gender partners
16:54 2013-11-27
we're trying to figure out the average
degree of man to the average degree of women?
// degree of a node
16:57 2013-11-27
Am: the average degree of opposite gender partners for men
Aw: the average degree of opposite gender partners for women
16:58 2013-11-27
We want to figure out Am / Aw?
16:58 2013-11-27
let's write some formulas:
Am == sum of all degrees / number of men
17:00 2013-11-27
that's just:
Am == number of edges / number of men
17:06 2013-11-27
we're going to see a lot of bogus studies
later!
17:08 2013-11-27
consider the problem of scheduling the final
exams!
17:09 2013-11-27
this may not be totally accurate, but roughly!
17:10 2013-11-27
here we use edge to denote the exams you can
not have together!
17:11 2013-11-27
some time slot
17:12 2013-11-27
the is an problem called the graph
coloring example!
17:12 2013-11-27
different time slots are colors, you
color the nodes of graph, but can not
have the same color for the nodes which
are adjacent!
17:13 2013-11-27
What is a Graph Coloring Problem?
Given a graph G & K colors, assign a color to
each node so adjacent nodes get different colors
17:14 2013-11-27
What is a chromatic number of a graph?
Def: The minimum value of K for which such
a coloring exists is the chromatic number
of a graph
17:15 2013-11-27
the chromatic number is usually denoted by
the χ(G)
17:16 2013-11-27
What's the meaning of a color?
it's just time slot
17:17 2013-11-27
adjacent nodes must not have the same color
(the same time slot)!
because these adjacent nodes don't like each
other!
17:22 2013-11-27
no one knows a fast algorithm for determing
a chromatic number?
17:23 2013-11-27
NP-complete problem
17:23 2013-11-27
NP-completeness
17:24 2013-11-27
there is the class of thousands of problems
are all np-complete!
17:24 2013-11-27
if you solve one of them(it's very hard),
you automatically solve all other in the
class!
17:25 2013-11-27
but if you just solved one of them, the
others will be solved quickly!
17:26 2013-11-27
so this is the central problem in computer
science!
17:26 2013-11-27
until they discover a fatal flaw, the proof
is bogus!
17:27 2013-11-27
hey, guy, there is no holy grail!
17:31 2013-11-27
most of the graph coloring algorithms
are based on this approach!
17:32 2013-11-27
Basic Coloring Algorithm for G = (V, E)
1st step: order the nodes V1, V2, ... , Vn
2nd step: order the colors C1, C2, ...,
// then we're going to process the nodes
// one of a time
3rd step:
for i = 1, 2, ..., n
color the nodes with the lowest legal color
17:38 2013-11-27
so different order results in different coloring!
17:38 2013-11-27
finding a clever ordering
17:39 2013-11-27
color the large degree nodes first!
17:40 2013-11-27
simulation helps!
17:41 2013-11-27
the facult says: NO, there is no way to get
them all compressed into a small number of
days!
17:42 2013-11-27
this algorithm is one of the example of what
is known as greedy algorithm!
17:45 2013-11-27
Theorem: If every node in G has degree <= d,
the Basic Algorithm uses at most d+1 colors for G
// you might do better!
17:47 2013-11-27
any idea of what proof technique we're going
to use?
17:49 2013-11-27
the answer is "proof by induction"
17:50 2013-11-27
I.H. == induction hypothesis
17:51 2013-11-27
you're going to have your predicate P(d)
17:54 2013-11-27
any questions about that?
17:55 2013-11-27
BaseCase: n == 1 => 0 edges => degree == 0
// color == d+1, true!
17:57 2013-11-27
What is the Inductive Step?
Assume P(n) is true for induction.
Let G = (V, E) be any (n+1) node graph. Let
d the maximum degree in G
17:59 2013-11-27
the basic algorithm:
first we order the nodes in any arbitrary order!
17:59 2013-11-27
for any n-node graph, I can coloring with d+1 colors
18:00 2013-11-27
How is the (n+1) node graph?
18:01 2013-11-27
order the nodes V1, V2, ..., Vn, Vn+1
remove Vn+1 from G to create G' = (V', E')
18:02 2013-11-27
and we will remove any edges tied to that node
18:02 2013-11-27
and this is the graph we're left with
18:02 2013-11-27
What is the maximum degree in G'?
18:03 2013-11-27
so we create a new graph by removing that node
18:04 2013-11-27
When I pull out a node, can the degree of any
node go up?
nope!
18:04 2013-11-27
so G' has maximum degree at most d!
18:05 2013-11-27
so we can use the induction hypothesis P(n)
18:06 2013-11-27
so let's look at the node Vn+1
18:07 2013-11-27
so all I have to do is color Vn+1!
18:11 2013-11-27
that means P(n+1) is true, and induction
is complete!
18:12 2013-11-27
you have constructed a paticularly graph!
18:18 2013-11-27
star graph
18:18 2013-11-27
complete graph
18:20 2013-11-27
the theorem just gives you an upperbound,
but the algorithm might do much better!
18:24 2013-11-27
that nasty example for the basic algorithm
is very much like that!
18:25 2013-11-27
nasty graph
18:25 2013-11-27
this is a world that you like everybody
except your spouse!
18:26 2013-11-27
so it has almost any edge but missing these!
18:28 2013-11-27
can you figure out a bad ordering for this
graph?
18:34 2013-11-27
What is a bipartite graph?
Def: A graph G = (V, E) is bipartite if V
can be partitioned(split) into VL, VR(left set & right set)
so that all the edges connect a node in VL to a node
in the right set
18:37 2013-11-27
you do win a million dollars for coloring a
graph with 3 colors, that's really hard!
18:40 2013-11-27
so there are pair of severs you cannot take down
at the same time!
18:42 2013-11-27
the same problem happens for register allocation!
18:43 2013-11-27
map coloring problem // 4 color theorem
18:45 2013-11-27
if 2 towers have overlapping area, they cannot
given the same frequency!
18:45 2013-11-27
frequency is very expensive
18:46 2013-11-27
What's the minimum number of radio frequencies
you need in order to enable all radio stations?
18:46 2013-11-27
edge between towers if they overlap
18:47 2013-11-27
four would work, but three is better!
18:49 2013-11-27
it's really a graph problem in disguise!
-------------------------------------------------

9:30 2013-11-28
mathematics for computer science, lec 7,
Matching problems
9:31 2013-11-28
the goal is to create maximum compatible pairs
9:33 2013-11-28
What is a matching problem?
Def: Given graph G = (V, E), a matching is a
subgraph of G where every node has a degree of 1
9:38 2013-11-28
is there a big matching in this graph?
9:38 2013-11-28
that's a matching of 3, so you have 3 couples together
9:41 2013-11-28
What is a perfect matching?
Def A matching is perfect if it has size |v| / 2!
// |v| is the number of nodes
9:42 2013-11-28
I'll put a compatibility edge here
9:42 2013-11-28
Does that graph has a perfect matching here?
9:44 2013-11-28
you can have a weighted graph, with every edge
with a weight on it!
9:49 2013-11-28
now the goal is find a matching with minimum
weight!
9:47 2013-11-28
What is the weight of a matching?
Def: The weight of a matching called m is the
sum of the weight on the edges of m!
9:50 2013-11-28
minimum weight matching
9:53 2013-11-28
What is a minimum weight matching?
Def: A minimum-weight matching for G is
a perfect matching for G with a minimum weight
9:56 2013-11-28
perfect matching
9:56 2013-11-28
minimum weight matching
9:58 2013-11-28
everybody has a preference
9:58 2013-11-28
preference list
10:00 2013-11-28
what if we put them in a desert,
and what might happen to them?
10:00 2013-11-28
rogue couple
10:01 2013-11-28
What is a rogue couple?
Def: Given a matching m, x & y form a rogue
couple if they prefer each other over their mates in m!
10:02 2013-11-28
that's sort of bad thing, it creates instability!
if you make the matching that way
10:02 2013-11-28
What does it mean by saying a matching is stable?
we say that the matching is stable if there
are not any vogue couples
10:04 2013-11-28
What is the goal?
the goal: find a perfect matching that is stable!
10:04 2013-11-28
If I put them in a desert, could I make a stable
matching?
10:06 2013-11-28
but really under that is a subgraph
10:09 2013-11-28
unisex scenario
10:10 2013-11-28
mergatoid???
10:10 2013-11-28
mergatoid's choice don't matter
10:11 2013-11-28
we'll state that as a theorem
10:11 2013-11-28
proof by contradiction
10:12 2013-11-28
without loss of generality
10:13 2013-11-28
WLOG == Without Loss Of Generality
10:17 2013-11-28
they both prefer to each other to their mates
10:20 2013-11-28
this statement/results is very famous!
10:20 2013-11-28
stable marriage problem
10:21 2013-11-28
What's the "Stable Marriage Problem"?
1. N boys & N girls
2. each boy has his own ranked list of all the girls
3. each girl has the same thing // preference list
the goal is to find a perfect matching without
rogue couples!
10:24 2013-11-28
preference list
10:25 2013-11-28
the girls also have there preference list!
10:29 2013-11-28
so let's try greedy algorithm
10:33 2013-11-28
the greedy algorithm will not work
10:37 2013-11-28
mating algorithm
10:37 2013-11-28
we will view this as a mate ritual
10:38 2013-11-28
goes under her balcony!
10:38 2013-11-28
in the afternoon the girl who has at least
1 suiter, pick her favorite!
10:39 2013-11-28
cross that girl out of his list
10:40 2013-11-28
but the termination condition is that you
have not more than 2 boys under 1 balcony!
10:42 2013-11-28
here I'm going to record the cross list
10:42 2013-11-28
so that's the status on day 1
10:43 2013-11-28
A is no longer possible for them
10:45 2013-11-28
the termination condition invokes!
10:47 2013-11-28
boy 1 paired to its 3rd choice!
10:56 2013-11-28
in fact, we just argue that this is
stable match!
10:58 2013-11-28
TMA == The Matching Algorithm
10:58 2013-11-28
What we need to show?
1. the TMA terminates
2. everyone gets married
3. there are no rogue couples
10:59 2013-11-28
What other we needs to show?
4. it runs quickly
11:05 2013-11-28
the average likeness between couples,
but we did not have a notion for how happy they're?
11:06 2013-11-28
Is this algorithm good for boys or good for girls?
// fairness
11:06 2013-11-28
so let's start to show that TMA terminates &
terminates quickly!
11:13 2013-11-28
Theorem 1: TMA terminates in <= N * N + 1 days
proof by contradiction
11:14 2013-11-28
we're going to show that leads to a contradiction!
11:15 2013-11-28
let's state that as a claim:
If we don't terminates on a day, then it must be
that more than 2(>=2) boys waiting outside the balcony
of 1 girl, then some boy(s) must cross a girl off his list
that night!
11:17 2013-11-28
so we measure progress using cross list!
11:18 2013-11-28
there're n list, n names, that implies there
are at most N * N crossout!
11:19 2013-11-28
after you make enough progress, you're done!
11:19 2013-11-28
TMA == The Matching Algorithm
11:19 2013-11-28
that is true, something even stronger is true!
11:20 2013-11-28
to do that, we'll use some invariant
11:20 2013-11-28
yeah, that's a great invariant:
As the girl sitting on the balcony, things only
get better! cause she's always keeps the best
one around!
11:23 2013-11-28
As she rejects boys, she got someone better there
forever!
11:24 2013-11-28
Let P == "If a girl G ever rejected a boy B, then
G has a suitor who she prefers to B"
11:24 2013-11-28
Lemma 1: P is an invariant for TMA
11:25 2013-11-28
1st, we have to show that P is true at the beginning
11:26 2013-11-28
BaseCase: Day 0, No one rejected => true!
11:29 2013-11-28
InductiveStep: Assume P holds at end of day d
....
11:35 2013-11-28
Theorem 2: Everyone is married in TMA'
also proof by contradiction!
11:36 2013-11-28
Pf == Proof
11:36 2013-11-28
proof by contradiction:
Assume that some boy B is not married at the end,
he's rejected by everyone => every girl
have someone better than B! => every girl married
=> every boy is married # □
11:42 2013-11-28
Theorem 3: TMA produces a stable matching
// there is no rogue couple
11:42 2013-11-28
proof by contradiction: assume there is rogue couple!
11:45 2013-11-28
that means they're not rogue, because Bob
likes his wife better than Gail!
11:48 2013-11-28
so that means that there is no rogue couples,
that means TMA is stable!
11:51 2013-11-28
TMA gives you a unique answer, but there may
exists other stable matchings!
11:52 2013-11-28
there is a lot of criteria you can use!
11:52 2013-11-28
this is probably the most practical approach
to matching out there
11:54 2013-11-28
the last thing is fairness
11:55 2013-11-28
who thinks it's favorable to boys(or girls)?
11:55 2013-11-28
it seems it's good for girls
11:54 2013-11-28
which is better, proposals or acceptors?
11:56 2013-11-28
it turns out we can answer this question in a
very clear way!
11:56 2013-11-28
ans == the boys have all the power,
it's very favorable to the boys!
11:57 2013-11-28
Let S = set of all stable matchings
11:57 2013-11-28
we already know that S is not empty!
11:58 2013-11-28
for each person P, we define the realm of
possibility for P to be the set of mates that
you might in a stable matching
12:02 2013-11-28
you say sometimes going out with somebody,
and your parents saying: "Oh, they're not in
your league!"
12:03 2013-11-28
this is the mathematical formulation for that
12:04 2013-11-28
Brad is not in Jenn's "realm of possibility"!
12:06 2013-11-28
you can define who your optimal mate is &
who your pessimal mate is!
12:06 2013-11-28
What is a person's optimal mate?
A person's optimal mate is his/her favorite
from the realm of possibility.
12:07 2013-11-28
What is a person's pessimal mate?
A person's pessimal mate is his/her least favorite
from the realm of possibility
12:08 2013-11-28
Theorem 4: TMA marries every body with his optimal mate
12:08 2013-11-28
Theorem 5: TMA marries every girl with her pessimal mate
12:10 2013-11-28
proof by contradiction:
Suppose for the purpose of contradiction that there
exists a stable matching m where some girl
G who fares worse than in TMA
12:13 2013-11-28
let B be her mate in TMA!
12:13 2013-11-28
because we said that she did worse in m
than she did in TMA!
thus she likes B better
12:14 2013-11-28
What is thoerem 4 says?
12:16 2013-11-28
we can derive that m is not stable!
but we assume m is stable, so we got
a contradiction #
12:16 2013-11-28
at the end of medical school, there is
a big day called match day, you will be
assigned to a hospital for your internship,
and the way that works is using this algorithm,
who do you think it's the boys? the hospital!
12:18 2013-11-28
this(TMA) is used in online dating as well
for the obvious reasons
12:19 2013-11-28
cost/performance trade
------------------------------------------------
14:36 2013-11-28
start mathematics for computer science, lec 8
Graph Theory II, minimum spanning tree
14:37 2013-11-28
ST == Spanning Tree
14:55 2013-11-28
MST == Minimum Spanning Tree
14:56 2013-11-28
Walks & Paths
14:57 2013-11-28
What is a walk?
Def: A walk is a sequence of vertices that
are connected by edges
14:57 2013-11-28
G == (V, E)
// G == Graph, V == Vertice, E == Edge
15:01 2013-11-28
What is a path?
Def: A path is a walk where all vertices are different!
15:02 2013-11-28
it's possbile to construct a path from a walk!
15:03 2013-11-28
Lemma: If there exists a walk from u to v, then
there also exists a path from u to v
15:08 2013-11-28
What is a "well ordering principle"?
15:10 2013-11-28
By the well ordering principle, there exists
a walk of minimum length
15:11 2013-11-28
since this is a walk of minimal length
15:17 2013-11-28
suppose walk is not a path, there exist i != j,
such that Vi == Vj
15:19 2013-11-28
if you have a walk, you can create a path
15:20 2013-11-28
connectivity
15:20 2013-11-28
What is a connectivity?
Def: 2 vertices u & v are connected if there
is a path from u to v
15:21 2013-11-28
What is a connected graph?
Def: A graph is connected when every pair
of vertices in the graph are connected
15:22 2013-11-28
a graph that is not connected may look like this!
15:24 2013-11-28
Cycles & Closed Walks
15:24 2013-11-28
What is a closed walk?
Def: A closed walk is a walk which starts & ends
at the exactly same vertex
15:25 2013-11-28
What is a cycle?
if k >= 3, and all vertices are different, then
we're saying that we have a cycle
15:26 2013-11-28
What is a tree?
1. tree is a graph
2. tree is connected graph
3. tree has no cycle
15:27 2013-11-28
What is a tree?
Def: A connected and acyclic graph is called a tree
15:28 2013-11-28
What is a leaf?
a leaf is a vertex which has degree of 1
15:29 2013-11-28
What is a leaf?
a leaf is a node with degree 1 in a tree
15:32 2013-11-28
Lemma: Any connected subgraph of a tree is a tree
15:37 2013-11-28
Lemma: A tree with n vertices has n-1 edges
so how to prove this Lemma?
15:41 2013-11-28
use proof by induction
induction hypothesis:
P(n) is "there are n-1 edges in any n-vertex tree"
15:42 2013-11-28
BaseCase + InductiveStep
15:43 2013-11-28
suppose P(n) for the purpose of induction
15:43 2013-11-28
so how can we use the induction hypothesis here?
15:44 2013-11-28
What kind of structure can I remove from a tree
that still stay a tree?
15:45 2013-11-28
What kind of vertex can I remove here?
leaf!
15:46 2013-11-28
by deleting a leaf, we still got a connected
subgraph
15:47 2013-11-28
because we delete a leaf, we'll reattach it!
15:49 2013-11-28
G == (V, E)
// G == Graph, V == Vertex, E == Edge
15:51 2013-11-28
so this is how the lemma is proved
15:51 2013-11-28
ST == Spanning Tree
15:52 2013-11-28
now let's talk very special trees, spanning trees
15:51 2013-11-28
What is a ST(Spanning Tree)?
Spanning tree is a subgraph of a graph somehow
spans all the vertices of the graph
15:56 2013-11-28
for every connected graph, we can create
such a spanning tree(ST)
15:58 2013-11-28
so let's define a spanning tree
15:58 2013-11-28
What is a spanning tree(ST)?
Def: a spanning tree(ST) of a connected graph
is a subgraph that is a tree with the same vertices
as the graph
16:00 2013-11-28
Theorem: Every connected graph has a spanning tree(ST)
// proof by contradiction
let T be a connected subgraph of G with all
the vertices as G and with the smallest number
of edges possible!
16:17 2013-11-28
All vertices in G are still connected after
removing e from T
16:18 2013-11-28
so our original assumption is wrong:
there does not exist such a connected subgraph
G has no ST
16:19 2013-11-28
MST == Minimum Spanning Tree
16:21 2013-11-28
let's construct a spanning tree
16:22 2013-11-28
so the weight of this paticular spanning tree
is 19!
16:22 2013-11-28
so how we create a Minimum Spanning Tree(MST)?
16:27 2013-11-28
let' first define what a Minimum Spanning Tree is?
Def: the MST of an edge-weighted graph G is the ST of G
with the smallest possible sum of edge weights
16:31 2013-11-28
What's the algorithm?
Algorithm: Grow a subgraph one edge at a time s.t.
at each step:
Add the minimum weight edge that keeps the subgraph
acyclic
16:32 2013-11-28
so this is our algorithm
16:33 2013-11-28
so this is the 1st edge I chose
16:34 2013-11-28
these are 2 disjoint edges, there definitely
has no graph!
16:35 2013-11-28
I don't choose that edge, because that weil
create a cycle!
16:39 2013-11-28
the algorithm creates a MST for you!
16:40 2013-11-28
Lemma: let S' consist of the first m edges selected
by the algorithm, There exists a MST T == (V, E)
for G, S' is a subset of E!
16:42 2013-11-28
Theorem: For any connected weighted graph G,
the algorithm produces a MST
16:43 2013-11-28
every connected graph has a MST, but here
we want to show that a "connected weighted graph"
has a MST!
17:13 2013-11-28
so if this lemma really hold true, then this theorem
can be shown!
17:15 2013-11-28
so let's state the induction hypothesis!
17:16 2013-11-28
the basecase is rather straightforward
/
9:57 2013-11-29 Friday
start mathematics for computer science, lec 9
communication networks
9:58 2013-11-29
How do you route the packet throught the networks?
9:59 2013-11-29
highly structured networks
10:00 2013-11-29
complete binary tree
10:02 2013-11-29
switch: direct packet through the network
10:02 2013-11-29
the packet is the fixed-size piece of data
10:03 2013-11-29
terminal □
switch ○
10:03 2013-11-29
What is a terminal?
terminal is like a computer or something,
it's actually the source & destination of data
10:06 2013-11-29
Binary Tree
10:07 2013-11-29
this is the root of a tree
10:08 2013-11-29
obviously I can reach from any input to any output
10:09 2013-11-29
see how well this behaved?
10:10 2013-11-29
latency
10:10 2013-11-29
What is a latency?
latency is the time required for a packet to
travel from an input to an output
10:13 2013-11-29
Diameter
10:13 2013-11-29
What is a Diameter?
Diameter of a network is the length of the
shortest path between the input & output that
are furthest apart
10:18 2013-11-29
so this is the diameter of a general binary tree
10:20 2013-11-29
Why don't we use a larger-size switch?
10:21 2013-11-29
so if I increase the switch size, the diameter
of the binary tree decreases!
10:23 2013-11-29
switch size: 2 * 2 or 3 * 3
10:24 2013-11-29
the amount of hardware we have to put into it
10:26 2013-11-29
What's the problem with this graph?
10:27 2013-11-29
congestion
10:27 2013-11-29
this route is actually loaded
10:27 2013-11-29
this bring us to the idea of congestion
10:28 2013-11-29
What is a permutation?
A permutation is a function Π: {0, ..., N-1}
-> {0, ..., N-1} such that no two numbers are mapped
to the same value
10:31 2013-11-29
no 2 numbers mapped to the same value
10:32 2013-11-29
permutation routing problem
10:33 2013-11-29
What is a permutation routing problem?
For each i, we want to direct the packet
at input i to output Π(i)
10:34 2013-11-29
identity permuation: i == Π(i)
10:37 2013-11-29
all the packet need to go through this switch
10:38 2013-11-29
the path taken is denoted by P(i, Π(i))
10:40 2013-11-29
What is the congestion of paths P(0, Π(0)),
P(1, Π(1)), .., P(N-1, Π(N-1)) is equal to the
larget number of paths that pass through a single
switch
10:43 2013-11-29
we have to direct all the packets through
the route & that is the worst(most access) switch
10:44 2013-11-29
the congestion here is equal to 4!
10:45 2013-11-29
the maximum congestion, that is the
worst case scenario!
10:45 2013-11-29
max congestion
10:48 2013-11-29
they all connected to their terminals,
we have switches
10:49 2013-11-29
so how does this work?
10:49 2013-11-29
first let's figure out what the diameter
is: what's the shortest path from between
the furthest input & output?
10:51 2013-11-29
the switch size is 2 * 2 // 2 inputs -> 2 outputs
10:52 2013-11-29
but over here, we can do much better
10:53 2013-11-29
Theorem: the congestion of an N-inputs array
is just 2!
10:54 2013-11-29
let's state one of them, and see how it's proved
10:57 2013-11-29
this is very good solution to the routing problem
10:58 2013-11-29
because a packet can only from the left or from
the top, at most 2 packets will go throught this
switch
11:00 2013-11-29
now the proof is complete!
11:01 2013-11-29
the idea is construct a butterfly network
11:13 2013-11-29
so this is a very small butterfly structure!
11:13 2013-11-29
we will repeat this process!
11:14 2013-11-29
we can combine 2 small butterfly structure
to get a bigger one!
11:16 2013-11-29
butterfly subnetwork
11:17 2013-11-29
binary tree style of feeling
11:21 2013-11-29
switch is uniquely identified by its row
& column
11:26 2013-11-29
we can figure out how to direct input to output
11:32 2013-11-29
for every bit that are differnet, I cross, otherwise
I go straightforward!
11:34 2013-11-29
How to evaluate the switch network?
1. Diameter
2. Switch size
3. #Switches
4. Congestion
11:42 2013-11-29
back-to-back
11:46 2013-11-29
the structure again has recursive natrue
to it!
11:47 2013-11-29
the top subnetwork is also a Benes network!
11:48 2013-11-29
the congestion however completely drop down
to zero!
11:49 2013-11-29
Why Benes network completely eliminate congestions?
???
11:51 2013-11-29
we will gain a lot of intuition about how to
solve this!
11:52 2013-11-29
Theorem: The congestion of the N-input Benes
network is 1, when N == exp(2, a) for some a >= 1
11:53 2013-11-29
we will use the induction on a,
P(a) == "The theorem is true for a"
11:55 2013-11-29
notice in this stage, we only have the most
elementary butterfly network!
11:56 2013-11-29
so let's take any permutation, we want to show
that we can route it in such a way that only has
a congestion of 1
12:00 2013-11-29
again every switch only see a packet once!
12:02 2013-11-29
map these input according to the permutation
of our choice!
12:03 2013-11-29
the intution is the we're going to set up
a constraint graph that represent all the
constaints we must satisfy in order to achieve
a congestion of 1
12:08 2013-11-29
we want to make sure that for this switch
only see 1 packet!
12:09 2013-11-29
let me define a "constraint graph"!
12:09 2013-11-29
What is a constraint graph?
If two packets must pass through different
subnetworks, then there is an edge between
them
12:16 2013-11-29
the packet destined for output 0 (Π(6) == 0)
and the packet for output 4 (Π(2) == 4) cannot
pass through the same subnetwork
12:19 2013-11-29
we need a constraint
12:22 2013-11-29
we use edge to represent constraint
12:25 2013-11-29
so in order to avoid congestion, we
have created this "constraint graph"
12:25 2013-11-29
the key insight is a 2-coloring of the
constraint graph
12:27 2013-11-29
it turns out that we can start our routing
process!
12:29 2013-11-29
red subnetwork,
blue subnetwork
---------------------------------------------
12:41 2013-11-29
start mathematics for computer science,
lec 10, Graph Theory III
13:56 2013-11-29
Ruler tour
13:57 2013-11-29
What is a Euler tour?
Def: An Euler tour is a walk traverses
every edge exactly once and start & finishes
at the same vertex
13:59 2013-11-29
Theorem: a connected graph has an Euler tour
iff every vertices has even degree
14:00 2013-11-29
so the proof consists of 2 parts
14:01 2013-11-29
Assume G = (V, E) has an Euler tour,
since every edge in E is traversed once,
14:02 2013-11-29
we want to show that every vertex has
degree of even!
14:08 2013-11-29
For G == (V, E), assume degree(v) is even
for every vertices v
14:09 2013-11-29
Let W be the longest walk that traverse no edge
more than once!
14:14 2013-11-29
All edges incident to Vk are used in W
let us try to prove this statement
14:19 2013-11-29
for Euler tour, we want every edge in the graph
is used in the tour!
14:20 2013-11-29
suppose for the purpose of contradiction that
W is not an Euler tour
because G is connected, if W is not an Euler tour,
so there exists an edge which is not used in W but
incident to some vertex that used in W
14:23 2013-11-29
Can we somehow get an contradiction?
14:26 2013-11-29
directed graph
14:26 2013-11-29
What's the difference between Euler tour
& Hamiltonian path?
Euler tour: every edges used only once!
Hamiltonian path: every vertices used only once!
14:28 2013-11-29
What's a digraph?
digraph == Directed Graph
14:29 2013-11-29
these are two separate edges
14:29 2013-11-29
incoming edges, outgoing edges
14:29 2013-11-29
indegree of vertex & outdegree of vertex
14:30 2013-11-29
I like to introduce "ajacency matrix"
14:31 2013-11-29
Theorem: Let G == (V, E) be a n-node graph
with V = {v1, v2,..., vn} now we
let A = {aij,..} the ajacency matrix for G
// if aij == 1, this means there is an edge from
// vertex i to vertex j
14:32 2013-11-29
directed walk in directed graph
14:33 2013-11-29
by taking the power of adjacency matrix
14:34 2013-11-29
number of directed walks of length k from vi
to vj
14:38 2013-11-29
How many of you know matrix multiplication?
14:45 2013-11-29
there is no such walk
14:50 2013-11-29
can we simplify this sum
14:58 2013-11-29
by the definition of matrix application
15:00 2013-11-29
then we will step into a very special graph:
tournament graph
15:01 2013-11-29
tree == acyclic, connected graph
15:01 2013-11-29
What it means for a directed graph to be
called connected?
15:02 2013-11-29
What does mean by saying a digraph is
strongly connected?
Def: A digraph G == (V, E) is strongly connected
if for all u, v in vertices, there exists directed
path from u to v in G
15:07 2013-11-29
acyclic graph
15:07 2013-11-29
DAG == Directed Acyclic Graph
15:08 2013-11-29
that will lead to partial ordering
15:08 2013-11-29
What is a DAG?
Def: A directed graph is called a Directed
Acyclic Graph(DAG) if it does not contain
any directed cycles
15:12 2013-11-29
tournament graph
15:12 2013-11-29
What is a tounament graph?
15:12 2013-11-29
we want to use the directed edges to
indicate who is winning from whom?
15:15 2013-11-29
eithe u beats v: u -> v
or v beats u: v -> u
15:18 2013-11-29
directed Hamiltonian path?
visit every vertices exactly once,
while Euler tour visit every edge exactly
once!
15:19 2013-11-29
What is a Directed Hamiltonian Path?
A directed Hamiltonian path is a directed
walk that visits every vertex exactly once
15:21 2013-11-29
Theorem: Every tournament graph actually contains
such a directed Hamiltonian path
15:22 2013-11-29
What kind of proof technique are we going
to use?
15:24 2013-11-29
so it make sense to use induction on the number
of nodes, so our induction hypothesis is
P(n) == "Every tournament graph with n-nodes
actually has a directed Hamiltonian path"
15:27 2013-11-29
so we have assumed P(n), so we want to prove
tounament graph with n+1 nodes
15:29 2013-11-29
so there must some subgraph already has this property!
15:29 2013-11-29
well let's take out 1 node, and see how that happens?
15:29 2013-11-29
What can we say about the remaining graph?
so we still have a tournament graph
15:31 2013-11-29
by P(n) we have a Directed Hamiltonian Path
15:32 2013-11-29
somehow we have to plug v(the vertex we delete)
into the graph
15:33 2013-11-29
so let's figure out what we can do here?
15:34 2013-11-29
so let us think a little bit...
15:36 2013-11-29
so yes this is a great observation...
15:38 2013-11-29
let's consider smallest i such that
v -> vi!
15:42 2013-11-29
so how do we reason about this?
15:43 2013-11-29
but why there would be a edge that
goes this way?
15:44 2013-11-29
so this is end of the proof
15:44 2013-11-29
you have a completely semmetric case
15:45 2013-11-29
that will contradicts our assumption
15:47 2013-11-29
so it's a great application of graph theory!
15:48 2013-11-29
either chicken v pecks chicken u: v -> u
or chicken u pecks chicken v: u -> v
so this is a tournament graph!
15:49 2013-11-29
u virtually pecks v?
15:49 2013-11-29
What does it mean by saying u virtually pecks v?
1. u -> v OR
2. there exists w s.t. u -> w -> v
15:51 2013-11-29
Can we really indicating a winning player?
15:51 2013-11-29
What is a King?
Def: A chicken that virtually pecks every other
chicken is called a King chicken
15:53 2013-11-29
so who in the pecking party is going to King?
15:54 2013-11-29
so we can have multiple King chickens here
15:55 2013-11-29
so this one is definitely the loser of the 4
15:55 2013-11-29
so what would be a good intuition?
15:56 2013-11-29
Theorem: the chicken with highest outdegree is
definitely a King
// proof by contradiction
15:57 2013-11-29
Let U has the highest outdegree,
suppose for the purpose of contradiction
u is not a King
15:59 2013-11-29
What does it mean by saying u is not a King?
it means either one of the conditions must be
violated, there exists a vertex v, which is
not pecked & not virtually pecked by u!
16:00 2013-11-29
virtually peck
16:02 2013-11-29
Can we formalize that a little bit better?
16:05 2013-11-29
so that's the end of this proof
------------------------------------------
16:17 2013-11-29
start mathematics for computer science,
lec 11, Relations, Partial Ordering
16:18 2013-11-29
What will be talked?
1. Relations
2. Partial Ordering
3. Parallel Task Scheduling
16:19 2013-11-29
Relation
16:19 2013-11-29
What is a Relation?
A relation from a set A to a set B is really
a set R which is a subset of A * B
16:29 2013-11-29
give an example of relation?
Ex R = {(a, b) : student a is taking class b}
16:45 2013-11-29
What is a relation on A?
A relation on A is a subset R...
16:47 2013-11-29
equivalent relations
16:52 2013-11-29
actually relations is not more than a
directed graph
16:53 2013-11-29
Set A together with R is a directed graph
G == (V, E) with V == A, E == R
16:54 2013-11-29
all the directed edges really represent
the relations!
16:55 2013-11-29
Properties:
A relation R on A is
1. reflexive: if xRx for all x ∈A
2. symmetric: if xRy => yRx for all x, y ∈A
3. antisymmetric: if xRy && yRx => x == y
4. transitivity: if xRy && yRz => xRz
16:59 2013-11-29
Are they Reflexive? Symmetric? Antisymmetric? Transitive?
17:00 2013-11-29
x ≡ y (mod 5) // x is congruent to y modulo 5
it's reflexive == true, symmetric == true
antisymmetric == false, transitive == true
17:03 2013-11-29
What about divisibility?
x | y
17:04 2013-11-29
Is it reflexive?
x | x is true
17:04 2013-11-29
Is it symmetric?
4 | 16 but NOT 16 | 4
symmetric == false,
antisymmetric == true
17:05 2013-11-29
Is it transitive?
4 | 16, 16 | 32 => 4 | 32
so it's transitive!
17:06 2013-11-29
so this paticular relation does not hold
in general
17:07 2013-11-29
equivalence relation
17:07 2013-11-29
partial order
17:07 2013-11-29
What is an equivalence relation?
An equivalence relation is
1. reflexive
2. symmetric
3. transitive
17:09 2013-11-29
equivalent class
17:09 2013-11-29
What is an equivalent class?
The equivalent class of x ∈A is the
set of all elements in A related to x
by our relation R
denoted by [x]
17:11 2013-11-29
x ≡ y (mod 5) // x is congruent to y modulo 5
[7] == {..., -3, 2, 7, 12, 17, 22...}
[7] == [12] == [17]...
17:14 2013-11-29
partition
17:14 2013-11-29
What is a partition?
A partition A is a collection of disjoint
nonempty set A1 ~ An which are all subset
of A, whose union is A
17:19 2013-11-29
Theorem: the equivalence class of an equivalence
relation on the set A form a partition of A
17:20 2013-11-29
so let's talk about partial orders
17:21 2013-11-29
A relation is a (weak) partial oder if it's
reflexive, antisymmetric, transitive
17:22 2013-11-29
weak partial oder
strong partial order
17:22 2013-11-29
strong version of a partial order
17:23 2013-11-29
A partial order relation is denoted differently,
instead of R!
17:25 2013-11-29
poset
17:25 2013-11-29
What is a poset?
poset == partially order set
17:26 2013-11-29
poset can be described by a directed graph
(A, <=_
17:26 2013-11-29
A poset is a directed graph with vertex set A
and edge set <=
17:33 2013-11-29
you have transitivity in this example
17:35 2013-11-29
self-loop
17:36 2013-11-29
Hasie diagram
17:36 2013-11-29
What is a Hasie diagram?
A Hasie diagram for a poset (A, <=) is a
directed graph with the vertex set A and
the edge set <=
* take self-loops
* take edges implied by transitivity
17:39 2013-11-29
you can see a clear order in this particular
graph
17:40 2013-11-29
Theorem: A poset has no directed cycles other
than self-loops
17:43 2013-11-29
I know the partial order is
* reflexive
* antisymmetric
* transitive
17:48 2013-11-29
there is no directed cycles other than
the self-loop
17:48 2013-11-29
poset == partially order set
17:49 2013-11-29
after deleting a self-loops from a poset,
we actually get a DAG(Directed Acyclic Graph)!
// this is very important property for the poset
17:52 2013-11-29
a & b are incomparable if neither a <= b or b <= a
a & b are comparable if a <= b or b <= a
17:53 2013-11-29
total order, partial order
17:53 2013-11-29
What is a total order?
A total order is a partial order in which every
pair of elements is comparable
17:54 2013-11-29
What kind of graph would that be?
17:56 2013-11-29
topological sort
17:57 2013-11-29
What is a topological sort?
If a total order is consistent with partial order,
then it is called a topological sort
17:58 2013-11-29
a topological sort of a poset is formally defined
as a total order (A, <=t), such that <= is a subset
of <=t
18:01 2013-11-29
Theorem: Every finite poset has a topological sort
18:01 2013-11-29
minimal element
18:01 2013-11-29
I just take one of them(minimal elements)
18:02 2013-11-29
so essentially we're using induction
18:03 2013-11-29
minimal element, maximal element
18:03 2013-11-29
turns out that not every poset has an
minimal element:
Ex. (Z, <=)
18:05 2013-11-29
Lemma: Every finite poset has a minimal element
18:06 2013-11-29
What is a chain?
Def: A chain is a sequence of distinct elements
such that a1 <= a2 <= .... <= at // t is the length
18:09 2013-11-29
finite poset
-----------------------------------------------------
//
15:06 2013-11-30 Saturday
start mathematics for computer science,
lec 12, sums
18:27 2013-11-30
Def: An n-year $m-payment annuity pays m dollars
at start of each year for n years
18:28 2013-11-30
it's pretty important to understand
how much this worth?
18:30 2013-11-30
always better to have cash in hand
18:32 2013-11-30
Assumption: Fixed interest rate p
18:34 2013-11-30
in 3 years from today, 1 dollar is worth
(1 + p) cubed!
18:36 2013-11-30
1 dollar in 1 year is worth 1 / (1 + p) now
1 dollar in 2 years is worth 1 / (1 + p) * (1 + p) now!
18:37 2013-11-30
so let's use this conclusion to figure out
the current value of the annuity!
18:40 2013-11-30
so the total current value is the sum...
18:40 2013-11-30
that's what you should pay today for the annuity
18:41 2013-11-30
let's put the sum into some form more familiar
18:41 2013-11-30
this might be familiar
18:41 2013-11-30
this is a nice close-form
18:45 2013-11-30
Perturbation method
18:46 2013-11-30
what we need to do is perturb it!
then subtract to get big concellation!
18:46 2013-11-30
almost everything cancels
18:47 2013-11-30
everything cancels, life is nice!
18:56 2013-11-30
cause the money grows in value
19:05 2013-11-30
these are all example of "geometric series"
19:08 2013-11-30
let's try the purtabation method
19:09 2013-11-30
geometric series
19:11 2013-11-30
OK, so that's the close-form expression for
that sum
19:15 2013-11-30
derivative method
19:23 2013-11-30
What would you pay to buy that company?
19:26 2013-11-30
we plug x = 1 / (1 + p)
19:28 2013-11-30
even a company that pay you more & more
each year still have a finite value
19:36 2013-11-30
you might guess the form of the solution
19:37 2013-11-30
starting get some constraint on the coefficient
19:40 2013-11-30
it turns out that anytime summing powers, you
get a result one higher-order
19:42 2013-11-30
there does not always have a closed-form formula?
1 + sqrt(2) + sqrt(3) + ...
19:43 2013-11-30
replacing the sum with an integral
19:44 2013-11-30
integration bounds
19:51 2013-11-30
I want to get bounds on the sum using
integral
19:53 2013-11-30
that's the lower bound on our sum
19:53 2013-11-30
upper bound, lower bound
20:01 2013-11-30
I've contained all the rectangles now
for the rectangle
20:02 2013-11-30
now I know the sum is at least this &
at most that!
20:08 2013-11-30
so my gap get bigger as n get bigger
20:09 2013-11-30
there is a special notation people use
20:09 2013-11-30
the leading term here is ...
20:09 2013-11-30
error term
20:13 2013-11-30
What does it mean by using ~?
Def: g(x) ~ h(x) means lim as x -> infinity
g(x) / h(x) == 1
20:14 2013-11-30
the limit as n goes infinity
20:17 2013-11-30
now some judgement take place
20:21 2013-11-30
asymptoticly the same
20:22 2013-11-30
which means this thing is really unimportant
20:23 2013-11-30
integration bounds when f is decreasing & positive
20:25 2013-11-30
so let's go the general picture again
20:27 2013-11-30
the integral is the area under this curve
20:28 2013-11-30
if I take the area under this curve &
add f(1), what do I get?
upperbound on my sum
20:30 2013-11-30
now for the lowerbound, think about shifting
the curve left by one!
20:31 2013-11-30
the area under the curve did not change
shifting left by 1
20:36 2013-11-30
so these bounds are really close here
20:37 2013-11-30
error term
20:38 2013-11-30
so if I use the tilder notation
20:40 2013-11-30
I don't hurt myself by dropping the ...
20:40 2013-11-30
I make a lowerbound
---------------------------------------------
20:48 2013-11-30
start mathematics for computer science,
lec 13, sums & asymptotics
20:49 2013-11-30
center of mass
20:49 2013-11-30
stack of blocks
20:52 2013-11-30
Is it possbile to get a block all the way
out of the table?
21:01 2013-11-30
oh, they're getting close!
21:03 2013-11-30
you're not the most efficient, that's for
sure!
21:06 2013-11-30
now what I want to do is analyzing this strategy!
21:08 2013-11-30
greedy algorithm
21:08 2013-11-30
theory is always easier than practice!
21:09 2013-11-30
we're going to analyze that strategy
and see how far it goes?
21:10 2013-11-30
Greedy Strategy:
Given n blocks of length 1
Def: ri == amoutn by which ith block extends
beyond the table
21:13 2013-11-30
the constraint is the stability constraint:
the center of mass Ck of the top k blocks
must lie on the (k+1)st block
table == block n+1
21:15 2013-11-30
now for the greedy stacking, where is the center
of mass of the k block?
what is the Ck?
21:17 2013-11-30
for greedy stacking, Ck == Rk+1
21:20 2013-11-30
the center of mass of kth block is at rk - 1/2
// the length of block is 1
21:20 2013-11-30
the center of mass of the top k blocks is
21:21 2013-11-30
now we got an recursive expression for Ck
21:29 2013-11-30
harmonic sum, harmonic numbers
21:35 2013-11-30
integration bounds for decreasing sum
21:38 2013-11-30
now we can just plug in & get really bounds
21:39 2013-11-30
so that's really good, we got rather tight bounds
21:40 2013-11-30
ln(n) // the natrual log of n
21:42 2013-11-30
Euler's constant
21:52 2013-11-30
integration bounds for increasing sum
22:02 2013-11-30
people put a lot of effort to get really
tight bound on factorial!
it's called Stirling's Formula
22:08 2013-11-30
Asymptotic Notation
22:08 2013-11-30
tilde notation(~)
22:09 2013-11-30
What is the tilde notation?
f(x) ~ g(x)
if lim f(x) / g(x) == 1 as x -> infinity
22:10 2013-11-30
What is the big-O notation?
f(x) = O(g(x)) if lim |f(x) / g(x) | < infinity (finite)
as x -> infinity!
// this means f(x) grow slower or in the
// same order as g(x) as x -> infinity
22:14 2013-11-30
f(x) is O(g(x)), which really means that
f(x) ∈O(g(x))
22:15 2013-11-30
O(g(x)) is a set of functions which grows
slower than g(x)
22:22 2013-11-30
in fact, I can take any quadratic polynomial
22:28 2013-11-30
f is upperbounded by g
22:29 2013-11-30
any polynomial grows slower than any exponential
22:38 2013-11-30
because the whole point of big-oh is upperbound
22:39 2013-11-30
that is omega symbol // lowerbound version
22:49 2013-11-30
up to constant factors
23:03 2013-11-30
that's a great observation
23:06 2013-11-30
this is the difference between a scalar & function
23:07 2013-11-30
never use asymptotic notation in inductive predicate!
-----------------------------------------------------
23:08 2013-11-30
start mathematics for computer science, lec 14
divide & conquer recurrence
23:09 2013-11-30
recurrent problem
23:13 2013-11-30
Tower of Hanoi
23:19 2013-11-30
recurrent problem
23:19 2013-11-30
recursive solution
//
9:16 2013-12-1
start mathematics for computer science,
lec 14, Divide & Conquer, recurrent problems
9:17 2013-12-1
solve it recursively
9:22 2013-12-1
let's prove that, let's get a lowerbound
9:23 2013-12-1
that's the optimal!
9:29 2013-12-1
there is a bunch of method which you can use!
9:29 2013-12-1
the simplest method:
guess & verify, also knows as the substitution
method
9:41 2013-12-1
Plug & Chug
9:41 2013-12-1
now I do a little chugging here
9:44 2013-12-1
now we try to observe the pattern
9:47 2013-12-1
mergesort
9:47 2013-12-1
the 1st thing we're going to do is
recursively sorting the first part of list
9:58 2013-12-1
How many comparisons do I have to do
to produce the...?
10:03 2013-12-1
merging takes n - 1 comparisons
2 * T(n/2) comparisons for recursive sorting
=> T(n) == 2 * T(n/2) + n - 1
10:15 2013-12-1
much better than a naive sorting algorithm
10:19 2013-12-1
What's the critical difference here?
10:19 2013-12-1
and that makes an enormous difference
10:20 2013-12-1
ceiling function, floor function
10:38 2013-12-1
verify by strong induction hypothesis
10:50 2013-12-1
real number, integer
10:53 2013-12-1
Divide & Conquer Recurrence has the form
11:00 2013-12-1
Divide & Conquer Recurrence
11:00 2013-12-1
Is Tower of Hanoi a Divide & Conquer Recurrence?
Tower of Hanoi is not Divide & Conquer
11:01 2013-12-1
but mergesort is divide & conquer
11:21 2013-12-1
this works for nasty guys too!
11:23 2013-12-1
I got to find a p for which is true!
11:26 2013-12-1
it doesn't give you the actually number,
it just gives you the asymptotic growth!
11:26 2013-12-1
so it's growing like this // growth pattern
11:27 2013-12-1
asymptotic growth
11:36 2013-12-1
let's look at this recurrence!
11:36 2013-12-1
this time is's not going to be nice!
----------------------------------------------
start mathematics for computer science,
lec 15, Linear Recurrence
16:19 2013-12-1
graduate student job problem
total number of jobs: m (fixed overtime)
16:27 2013-12-1
Q: when are all m jobs filled?
Boundary condition: 1st professor hired in year 1
16:28 2013-12-1
solution: Let f(n) == number of professors during year n
16:31 2013-12-1
Fibonacci Recurrence
16:32 2013-12-1
He published for the purpose of modeling
rabbit population
16:34 2013-12-1
Linear Recurrence
16:34 2013-12-1
What is a linear recurrence?
Def: A recurrence is said to be linear if it
is of the form f(n) == a1 * f(n-1) + a2 * f(n-2)
...+ad * f(n-d) for fixed ai & d, d is the order of the
recurrence
16:40 2013-12-1
now I can use the quadratic formula to solve
for alpha
16:41 2013-12-1
guess & verify works
16:41 2013-12-1
the golden ratio
16:42 2013-12-1
we'll just state that as a fact!
16:45 2013-12-1
w/o == without
16:47 2013-12-1
so let's see how to determine the constant factors!
we plug in the bounday conditions
16:48 2013-12-1
now I use the next boundary condition to
nail them down!
17:03 2013-12-1
this is a process you'll go through to do it!
17:03 2013-12-1
so we'll solve a general linear recurrence!
17:04 2013-12-1
and we got to have boundary conditions
17:06 2013-12-1
and I can rewrite this as a polynomial to zero!
17:07 2013-12-1
characteristic equation of the recurrence
17:07 2013-12-1
What you need to do is compute the solutions!
17:08 2013-12-1
in that case the solution is the linear combination
of their nth power!
17:09 2013-12-1
imaginary roots
17:10 2013-12-1
so you got a system of equations
17:11 2013-12-1
the system of equations is never degenerate,
it always have a solution!
17:13 2013-12-1
the tricky case is repeated roots!
17:14 2013-12-1
differential equation
17:15 2013-12-1
recurrence is just analogy of differential
equations!
17:18 2013-12-1
OK, let's set up the recurrence!
17:20 2013-12-1
What's the characteristic equation for this
recurrence?
17:21 2013-12-1
double root
17:25 2013-12-1
repeated roots
17:27 2013-12-1
verify by induction
17:28 2013-12-1
this works for all homogeneous case!
17:29 2013-12-1
linear recurrence
17:30 2013-12-1
solving inhomogeneous recurrence is 1 step
harder than the homogeneous recurrence!
17:31 2013-12-1
then I'll tell you how to solve that kind
of recurrence which is more general!
17:31 2013-12-1
inhomogeneous recurrence
17:34 2013-12-1
How to solve inhomogeneous recurrence?
step 1: Replace g(n) by 0, solve the homogeneous
recurrence(ignore boundary conditions for now)
step 2: Restore g(n), find any particular solution
(ignore boundary conditions)
step 3: Add the homogeneous & particular solutions
together, then use the boundary conditions
to get the answer
17:45 2013-12-1
general solution == homogeneous solution + particular solution
17:51 2013-12-1
so the tricky part here is guess the particular solution!
17:54 2013-12-1
guessing a particular solution!
17:55 2013-12-1
What you supposed to do in that case?
-----------------------------------------------------
//
10:32 2013-12-2 Monday
start mathematics for computer science, lec 16
Couting Rules I
10:35 2013-12-2
What is a set?
Def: A set is unordered collections of distinct elements
10:37 2013-12-2
cardinality
10:37 2013-12-2
What is the cardinality of a set?
Def: The size or cardinality of S
is the number of elements the set in S
denoted as |S|
10:38 2013-12-2
sequence
10:38 2013-12-2
What is a sequence?
Def: A sequence is a ordered collection of elements
elements are also called components or terms
these elements are not necessarily distinct
10:40 2013-12-2
permuation
10:40 2013-12-2
What is a permutation?
Def: A permutation of a set S is a sequence
that contains every element in S exactly once
10:42 2013-12-2
it turns out that we can do a few more!
10:43 2013-12-2
if I want to create a permuation of a set,...
10:46 2013-12-2
product rule
10:46 2013-12-2
permutations relates sets & sequence
10:47 2013-12-2
and that's what we want, we want to count
10:47 2013-12-2
function
10:47 2013-12-2
What is a function?
Def: A function f: X -> Y is a relation between
the set X & Y s.t. every element of X is related
to exactly one element of Y
10:50 2013-12-2
suppose we have mapping
10:55 2013-12-2
surjective function
10:55 2013-12-2
What is the surjective function?
Def f: X -> Y
is called surjective if every element in Y
is mapped to at least once
10:57 2013-12-2
so this particular example is not surjective
10:57 2013-12-2
injective
10:57 2013-12-2
What is a injective function?
a function f: X -> Y is called
injective if every element of Y is mapped at most once
11:00 2013-12-2
bijective
11:00 2013-12-2
What is a bijective function?
A function is bijective if it's both surjective & injective
11:07 2013-12-2
bijective iff surjective & injective
11:08 2013-12-2
let's talk the mapping rule
11:08 2013-12-2
Mapping Rule
1. S: X -> Y surjective => |X| >= |Y|
11:12 2013-12-2
bijection rule
11:15 2013-12-2
X == all the ways to select 12 donuts from 5 varieties
11:31 2013-12-2
bit sequence
11:34 2013-12-2
generalized pigeonhole principle
11:53 2013-12-2
this is what called a nonconstructive approach
11:58 2013-12-2
just by inspection, this is a very hard problem
to solve!
11:59 2013-12-2
so what do I do?
12:03 2013-12-2
nonconstructive proof
12:05 2013-12-2
What is a k-to-1 function?
Def: A k-to-1 function f: X -> Y maps
exactly k elements of X to every element of Y
12:06 2013-12-2
Division Rule
12:06 2013-12-2
What is a Division Rule?
If f is k-to-1: then |X| == k * |Y|
12:09 2013-12-2
If you have a bijection function,
the cardinality of the domain is equal to
the cardinality of the range!
12:16 2013-12-2
and I could create a mapping f that doing
it for me!
12:28 2013-12-2
generalized product rule
12:29 2013-12-2
What is a generalized product rule?
Let S be a set of length k sequence,
If there are n1 possible entries
n2 posssible choice for each entry...
12:33 2013-12-2
then the cardinality of the set can be
computed as
|S| == n1 * n2 * .... * nk
12:33 2013-12-2
so this is an example where we use the
generalized product rule
12:38 2013-12-2
In how many ways can I do this?
12:44 2013-12-2
let's see what is happening here?
12:45 2013-12-2
defective dollars, non-defective dollars
12:51 2013-12-2
a special case of a generalized product rule
is the product rule!
12:57 2013-12-2
sum rule
12:57 2013-12-2
What is a sum rule?
Sum Rule: If A1, A2,..., An are all disjoint,
then |A1 ∪ A2 ∪... ∪ An| == |A1| + |A2| + ... + |An|
13:00 2013-12-2
there are no interception between the sets
-----------------------------------------------------
13:14 2013-12-2
mathematics for computer science, lec 17
Couting Rules II
13:50 2013-12-2
inclusion / exclusion principle
13:50 2013-12-2
Inclusion-Exclusion
13:54 2013-12-2
this part of here is the intersection
of both sets
14:05 2013-12-2
and then we have to keep going like this
14:20 2013-12-2
I need to subtract their intersection
14:21 2013-12-2
so what kind of bijection could I have?
14:30 2013-12-2
Bookkeeper Rule
14:30 2013-12-2
What is a bookkeeper rule?
distinct copies of letters: l1, l2, l3, ..., lk
number of sequence with n1 copies of l1, n2 copies
of l2, n3 copies of l3..., nk copies of lk
14:38 2013-12-2
binomial theorem
14:38 2013-12-2
What is an Binomial Theorem?
14:49 2013-12-2
Poker Hands
15:08 2013-12-2
this is the generalized product rule
15:10 2013-12-2
suites == Heart, Spade, Diamond, Club
15:53 2013-12-2
combinational proofs
15:58 2013-12-2
Pascal's identity
----------------------------------------------
16:27 2013-12-2
review mathematics for computer science, lec 17
Counting Rules II
16:28 2013-12-2
Inclusion-Exclusion
16:44 2013-12-2
if you look at the cardinality of the whole
union of a bunch of sets

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值